Java Helpa4.pdfASSIGNMENT 4 A game and an email system.docxpriestmanmable
Java Help/a4.pdf
ASSIGNMENT 4 : A game and an email system
COMP-202, Winter 2014, All Sections
Due: Tuesday, 25th of March, 2014, 23:59
Please read the entire pdf before starting.
You must do this assignment individually and, unless otherwise specified, you must follow all the general
instructions and regulations for assignments. Graders have the discretion to deduct up to 10% of the value
of this assignment for deviations from the general instructions and regulations.
Part 1: 0 points
Part 2a: Question 1: 25 points
Part 2b, Question 1: 10 points
Part 2b, Question 2: 25 points
Part 2b, Question 3: 5 points
Part 2b, Question 4: 10 points
Part 2b, Question 5: 15 points
Part 2c, Question 1: 10 points
100 points total
It is very important that you follow the directions as closely as possible. The directions, while
perhaps tedious, are designed to make it as easy as possible for the TAs to mark the assignments by letting
them run your assignment through automated tests. While these tests will not determine your entire grade, it
will speed up the process significantly, which will allow the TAs to provide better feedback and not waste time
on administrative details. Plus, if the TA is in a good mood while he or she is grading, then that increases
the chance of them giving out partial marks. Marks can be removed if comments are missing, if the code is
not well structured, and if the problems your solution does not respect the assignment requirement.
Part 1 (0 points): Warm-up
Do NOT submit this part, as it will not be graded. However, doing these exercises might help you to do the
second part of the assignment, which will be graded. If you have difficulties with the questions of Part 1, then
we suggest that you consult the TAs during their office hours; they can help you and work with you through
the warm-up questions.
Warm-up Question 1 (0 points)
Write a class Vector. A Vector should consist of three private properties of type double: x,y, and z.
You should add to your class a constructor which takes as input 3 doubles. These doubles should be
assigned to x,y, and z. You should then write methods getX(), getY(), getZ(), setX(), setY(), and
setZ() which allow you to get and set the values of the vector.
Warm-up Question 2 (0 points)
Add to your Vector class a method calculateMagnitude() which returns a double representing the
magnitude of the vector. The magnitude can be computed by taking√
x2 + y2 + z2
1
Warm-up Question 3 (0 points)
Write a method scalarMultiply which takes as input a double[], and a double scale, and returns
void. The method should modify the input array by multiplying each value in the array by scale.
Question to consider: Would this approach work if we had a double as input instead of a double[]?
Warm-up Question 4 (0 points)
Write a method deleteElement which takes as input an int[] and an int target and deletes all
occurrences of target from the array. The method should return the new int[]. Question to con ...
1 ECE 175 Computer Programming for Engineering Applica.docxoswald1horne84988
1
ECE 175: Computer Programming for Engineering Applications
Homework Assignment 6
Due: Tuesday March 12, 2019 by 11.59 pm
Conventions: Name your C programs as hwxpy.c where x corresponds to the homework number and y
corresponds to the problem number. For example, the C program for homework 6, problem 1 should be
named as hw6p1.c.
Write comments to your programs. Programs with no comments will receive PARTIAL credit. For each
program that you turn in, at least the following information should be included at the top of the C file:
- Author and Date created
- Brief description of the program:
- input(s) and output(s)
- brief description or relationship between inputs and outputs
Submission Instructions: Use the designated Dropbox on D2L to submit your homework.
Submit only the .c files.
Problem 1 (15 points) Write a program that returns the minimum value and its location, max
value and its location and average value of an array of integers. Your program should call a
single function that returns that min and its location, max and its location and mean value of
the array. Print the results in the main function (not within the array_func function).
See sample code execution below. The declaration of this function is given below:
void array_func (int *x, int size, int *min_p, int *minloc_p, int *max_p, int *maxloc_p, double *mean_p)
/* x is a pointer to the first array element
size is the array size
min_p is a pointer to a variable min in the main function that holds the minimum
minloc_p is a pointer to a variable minloc in the main function that holds the location where the
minimum is.
max_p is a pointer to a variable max in the main function that holds the maximum
maxloc_p is a pointer to a variable maxloc in the main function that holds the location where the
maximum is.
mean_p is a pointer to a variable mean in the main function that holds the mean */
Declare the following array of integers within the main function:
Sample code execution:
int data_ar[] = { -3, 5, 6, 7, 12, 3, 4, 6, 19, 23, 100, 3, 4, -2, 9, 43, 32, 45,
32, 2, 3, 2, -1, 8 };
int data_ar2[] = { -679,-758,-744,-393,-656,-172,-707,-32,-277,-47,-98,-824,-695,
-318,-951,-35,-439,-382,-766,-796,-187,-490,-446,-647};
int data_ar3[] = {-142, -2, -56, -60, 114, -249, 45, -139, -25, 17, 75, -27, 158,
-48, 33, 67, 9, 89, 33, -78, -180, 186, 218, -274};
2
Problem 2 (20 points): A barcode scanner verifies the 12-digit code scanned by comparing the
code’s last digit to its own computation of the check digit calculated from the first 11 digits as
follows:
1. Calculate the sum of the digits in the odd-numbered indices (the first, third, …, ninth
digits) and multiply this sum by 3.
2. Calculate the sum of the digits in the even-numbered indices (the 0th, second, … tenth
digits).
3. Add the results from step 1 and 2. If the last digit of the addition result is 0, then 0 is the
check digit. .
ontents
· Introduction
· Objectives
· Configuration
· Shapes
· Controls
· Sounds
· Scoring
· Code Requirements
· Report
· Deliverables
· Grading
· Start Small
Introduction
The Final Project gives you the opportunity to apply the object-oriented software development skills you have acquired during the course to a significant but moderately-sized application. The following sections describe the general behavior of the application, the simulation, and the deliverable requirements for the project.
The final project for this class is a built upon your homeworks. You are going to create a very simple version of Asteroids, but with shapes.
I will also work through this with you and provide you a working demo on D2L by end of week 8
The template for the project is on D2L under Final Project.
Objectives
The objective is pretty simple. Create a keyboard driven video game, with you the player in the center of the screen. Shapes will enter the screen and you will need to shoot them. If any of the shapes collide with your ship your game will end.
What I will provide:
A template GUI to start with.
Trapping the keys and bound methods for them. You can find this
Configuration
Configuration.json is the games overall configuration file. Since this is a first attempt at such a project we may need to add additional parameters. You can use the ShapeParser as an example of how to parse this file. I would recommend you add additional utility methods to the Extractor utility class if needed. You may want to consider a singleton that stores all the configuration data. It will help you not only with design but the ability to hardcode debug values in it instead of having to constantly modify the configuration.json. The configuration file contains only best guesses as to what values to put in. You should adjust them accordingly for development then pick ones that are realistic for final release. Hint: By having slow speeds you can easily validate your game visually.
Below are the fields:
“game”– The main key for the file. Not used for anything internally.
“framespersecond” – int - The number of framespersecond, or the overall game speed. Use this value in Motion.java. Replace the ‘FRAMES_PER_SECOND’ with a call to your Configuration managers method for framespersecond.
“shotspeed” – float - The speed at which your shots will travel. Shots are not affected by friction.
“forwardthrust” – float - Each tap of the forward thrust increases the player’s x/y speed by 1. Remember in graphics ‘up’ is –y. I will provide you with the algorithms for this. Basically if the nose of the ship is at 0 degrees it’s cos 0 degrees, sin 0 degrees or +1.0x, 0y. If it’s at 45degress, it’s 1/sqrt(2), -1/sqrt(2), and at 0 its 0,-1. Again remember for y it’s inverted. I will double check to make sure this works.
"shapes" – float - This is the num.
I have to write a Connect Four game program When a player t.pdfaayushmaany2k14
I have to write a Connect Four game program. When a player takes their turn, they will select a
column in which to place a token. The token is placed at the top of the column and is allowed to
fall to the bottom, stacking on top of any previously placed tokens. Two players take turns placing
token colors of red or yellow. The first person to create four of their color token in a row,
horizontally or vertically, (NOT diagonally in this problem) wins and the game is over.
The program will display the board (7 columns and 6 rows), then ask for alternating players to
place a token in column 0 through 6. The process repeats until one player wins. You do not need
to check for a tie game, or if there is space in a chosen column.
The photos (shown below) contain the code for the game framework. It is required that I utilize
functions and write my code within the functions. The function signatures are provided for you in
the framework. Examine each one to see what will be needed by the end. I am given 2 functions to
start with: main() and display(board).
Part 1: Fill out the code for the placeToken function. It is given three parameters: (1) the board,
(2) the column in which to place a token, and (3) the token itself. The board is the two dimensional
list of characters, with spaces ' ' being empty locations. The column is a numerical index in which
to place the token, and the token is the character 'R' or 'Y'.
Start at the top row (index 0) and move down the rows until the row below is not ' ', then place the
token. Then return the row the token ended up in. You can test this out by running the program,
but the game won't end yet because the other functions are incomplete. Use control+C (command
+ C) to stop the game early.
Another way to approach this is to start at the bottom row and walk upwards until the space is ' '.
Part 2: Fill out the code for the winningMove function. The game is won if four tokens of the
same color line up either vertically or horizontally. Good functional design would have these
checks in their own functions. Fill in the code for winningMove such that it uses the 2 other check
functions (below). This function can be one line of code. The row and column parameters are the
location of the last move taken.
Part 3: Fill in the code for checkVertical, which checks for four in a line vertically (on the same
column) as the given row and column parameters. You only need to search outward from the row
and column parameters and not the whole board. Since new moves are controlled by gravity in
connect four, you only need to search downward. You can test if this is working by running the
program.
Part 4: Fill in the code for checkHorizontal, which checks for four in a line horizontally (on the
same row) as the given row and column parameters. You only need to search outward from the
row and column parameters and not the whole board. You can test if this is working by running the
program.
The last photo shows an example run..
This is an individual project, to be completed on your own. It i.docxabhi353063
This is an
individual
project, to be completed on your own. It is considered dishonest either to read someone else's solution or to provide a classmate with a copy of your work. Do not make the mistake of thinking that superficial changes in a program (such as altering comments, changing variable names, or interchanging statements) can be used to avoid detection. If you cannot do the work yourself, it is extremely unlikely that you can succeed in disguising someone else's work. We are adamant that cheating in any form is not tolerated. Even the most trivial assignment is better not done than if you cheat to complete it.
Prerequisites
Primitive types
Conditionals
Loops
Arrays
Learning Objectives
Problem Solving
Traversing and manipulating 2-dimensional arrays
Using nested loops
Introduction
In this project, you will implement the logic of the game
Othello
, also known as
Reversi
.
Game Rules
Othello is a strategy board game for two players on a squared checkered board. It is played with identical disks that are white on one side and black on the other. Players take turns placing disks on the board with their assigned color facing up.
The game starts with four disks placed in a square at the center of the board in a standard diagonal pattern: two facing white side up, two facing black side up and same-colored disk on a diagonal with each other. These four initial disks are
not
placed by the player.
The black player moves first. He must place a disk with the black side up on the board, in such a position that there exists
at least
one straight occupied line between the new disk and another dark disk, with one or more contiguous white disks
bounded
between them. During a move, all bounded disks of the opponent's color are turned over to the current's player color. A straight line involves: horizontal, vertical and diagonal lines in every possible direction.
It is possible to bound disks in more than one direction during a single move.
Players take turns to play. When a player doesn't have any valid moves, his turned is skipped. The game must keep going while there are valid moves by either player. The goal of the game is to have the
majority of the disks displaying your color
when there are no more possible moves.
We suggest that you play
an online version of the game
to grasp the idea.
Your Task
In this project, you will implement the rules and logic for Othello. You are provided with the skeleton code containing the
basic methods
that you need to complete to launch this game on the java console.
You have the freedom to use additional methods and variables to structure your solution, as long as the basic methods behave as expected.
Implementation Details
This project consists of just one class:
Othello
: it implements the logic of the game. You will implement the missing methods.
You should begin coding
after you have read the entire handout, understood the problem and made a plan for solving it.
Variables
The
Othello
clas ...
I have another assignment due for an advance java programming class .pdfFORTUNE2505
I have another assignment due for an advance java programming class that I do not understand
how to do. I don\'t know how to implement the comparable interface and sort the cards from
lowest to highest based on suit within rank. And I also dont understand how I am suppose to add
a static nested class that implements the comparator interface and then sort the cards lowest to
highest based on rank within a suit. Then I have to add the different buttons and I am not sure
which class that these buttons are to be placed in. The buttons I have to add are: Deal Button,
Fish Sort Button, Spades Sort Button, and a Reverse Toggle Button. The description for each
button is in the instructions below:
Program 4 – Sorting with nested classes and lambda expressions
This program is a bit different from our others. Just like the last program, you will start with the
project that is attached to this assignment. Remember to rename the project. You will lose points
if you do not. Also, remember that you need to submit an Eclipse project, not just Java files. You
will lose points there as well.
The main point of the exercise is to demonstrate your ability to use various types of nested
classes. Of course, sorting is important as well, but you don’t really need to do much more than
create the class that does the comparison. In general, I like giving you some latitude in how you
design and implement your projects. However, for this assignment, each piece is very specific as
to how I want you to implement things. There are a number of parts to this program. Make
certain you accomplish the two additions to the Card class early-on since much of the rest of
your program will depend on that work.
The requirements:
Properly named project, good code (avoid redundancy), nice UI, etc. (20 pts)
Implement the Comparable interface in the Card class. (15 pts)
Sort the cards lowest to highest based on suit within rank, e.g.
2 clubs
2 diamonds
2 hearts
2 spades
3 clubs
3 diamonds
etc.
Add a static nested class to the Card class that implements the Comparator interface. (15 pts)
Sort the cards lowest to highest based on rank within suit, e.g.
2 clubs
3 clubs
4 clubs
5 clubs
etc.
In the UI, add the following to your interface.
Deal Button (10 pts)
Implement the Deal action handler using an inner class (not local). You may want to pull some
of the code from the show method that is already there. Or better, put the common code into a
class and call it.
Fish Sort Button (15 pts)
Sort the code in a way that would be useful playing Go Fish. I.e. with all of the cards grouped
together. Implement the action handler using a lambda expression in the UI. The code in the
lambda expression should depend on the Card class for the actual sorting (i.e. the natural order).
It must not call any other method in the UI class.
Spades Sort Button (15 pts)
Order the cards in such a way that they would be useful playing Spades; i.e. with the cards sorted
by rank within suit and the suits in the order pro.
Agent tic tac-toe - an interactive game for computational thinkingLorennRuster
Agent Tic-Tac-Toe is an interactive game that explains how a programmed agent plays tic-tac-toe, enabling computational thinking skills.
You are a spy (Agent Jamie Bond). Your mission is to play the next move in a game of tic-tac-toe following a set of instructions contained in a series of envelopes. You will record your findings as you go, in your Agent Report. At the end of the game, you will have made the next move.
For increased difficulty, the game can be played in interaction with another team. In this case, the game can be repeated until a winning move is made.
A complete set of resources including classroom materials, curriculum notes and teacher notes can be found in this document.
Java Helpa4.pdfASSIGNMENT 4 A game and an email system.docxpriestmanmable
Java Help/a4.pdf
ASSIGNMENT 4 : A game and an email system
COMP-202, Winter 2014, All Sections
Due: Tuesday, 25th of March, 2014, 23:59
Please read the entire pdf before starting.
You must do this assignment individually and, unless otherwise specified, you must follow all the general
instructions and regulations for assignments. Graders have the discretion to deduct up to 10% of the value
of this assignment for deviations from the general instructions and regulations.
Part 1: 0 points
Part 2a: Question 1: 25 points
Part 2b, Question 1: 10 points
Part 2b, Question 2: 25 points
Part 2b, Question 3: 5 points
Part 2b, Question 4: 10 points
Part 2b, Question 5: 15 points
Part 2c, Question 1: 10 points
100 points total
It is very important that you follow the directions as closely as possible. The directions, while
perhaps tedious, are designed to make it as easy as possible for the TAs to mark the assignments by letting
them run your assignment through automated tests. While these tests will not determine your entire grade, it
will speed up the process significantly, which will allow the TAs to provide better feedback and not waste time
on administrative details. Plus, if the TA is in a good mood while he or she is grading, then that increases
the chance of them giving out partial marks. Marks can be removed if comments are missing, if the code is
not well structured, and if the problems your solution does not respect the assignment requirement.
Part 1 (0 points): Warm-up
Do NOT submit this part, as it will not be graded. However, doing these exercises might help you to do the
second part of the assignment, which will be graded. If you have difficulties with the questions of Part 1, then
we suggest that you consult the TAs during their office hours; they can help you and work with you through
the warm-up questions.
Warm-up Question 1 (0 points)
Write a class Vector. A Vector should consist of three private properties of type double: x,y, and z.
You should add to your class a constructor which takes as input 3 doubles. These doubles should be
assigned to x,y, and z. You should then write methods getX(), getY(), getZ(), setX(), setY(), and
setZ() which allow you to get and set the values of the vector.
Warm-up Question 2 (0 points)
Add to your Vector class a method calculateMagnitude() which returns a double representing the
magnitude of the vector. The magnitude can be computed by taking√
x2 + y2 + z2
1
Warm-up Question 3 (0 points)
Write a method scalarMultiply which takes as input a double[], and a double scale, and returns
void. The method should modify the input array by multiplying each value in the array by scale.
Question to consider: Would this approach work if we had a double as input instead of a double[]?
Warm-up Question 4 (0 points)
Write a method deleteElement which takes as input an int[] and an int target and deletes all
occurrences of target from the array. The method should return the new int[]. Question to con ...
1 ECE 175 Computer Programming for Engineering Applica.docxoswald1horne84988
1
ECE 175: Computer Programming for Engineering Applications
Homework Assignment 6
Due: Tuesday March 12, 2019 by 11.59 pm
Conventions: Name your C programs as hwxpy.c where x corresponds to the homework number and y
corresponds to the problem number. For example, the C program for homework 6, problem 1 should be
named as hw6p1.c.
Write comments to your programs. Programs with no comments will receive PARTIAL credit. For each
program that you turn in, at least the following information should be included at the top of the C file:
- Author and Date created
- Brief description of the program:
- input(s) and output(s)
- brief description or relationship between inputs and outputs
Submission Instructions: Use the designated Dropbox on D2L to submit your homework.
Submit only the .c files.
Problem 1 (15 points) Write a program that returns the minimum value and its location, max
value and its location and average value of an array of integers. Your program should call a
single function that returns that min and its location, max and its location and mean value of
the array. Print the results in the main function (not within the array_func function).
See sample code execution below. The declaration of this function is given below:
void array_func (int *x, int size, int *min_p, int *minloc_p, int *max_p, int *maxloc_p, double *mean_p)
/* x is a pointer to the first array element
size is the array size
min_p is a pointer to a variable min in the main function that holds the minimum
minloc_p is a pointer to a variable minloc in the main function that holds the location where the
minimum is.
max_p is a pointer to a variable max in the main function that holds the maximum
maxloc_p is a pointer to a variable maxloc in the main function that holds the location where the
maximum is.
mean_p is a pointer to a variable mean in the main function that holds the mean */
Declare the following array of integers within the main function:
Sample code execution:
int data_ar[] = { -3, 5, 6, 7, 12, 3, 4, 6, 19, 23, 100, 3, 4, -2, 9, 43, 32, 45,
32, 2, 3, 2, -1, 8 };
int data_ar2[] = { -679,-758,-744,-393,-656,-172,-707,-32,-277,-47,-98,-824,-695,
-318,-951,-35,-439,-382,-766,-796,-187,-490,-446,-647};
int data_ar3[] = {-142, -2, -56, -60, 114, -249, 45, -139, -25, 17, 75, -27, 158,
-48, 33, 67, 9, 89, 33, -78, -180, 186, 218, -274};
2
Problem 2 (20 points): A barcode scanner verifies the 12-digit code scanned by comparing the
code’s last digit to its own computation of the check digit calculated from the first 11 digits as
follows:
1. Calculate the sum of the digits in the odd-numbered indices (the first, third, …, ninth
digits) and multiply this sum by 3.
2. Calculate the sum of the digits in the even-numbered indices (the 0th, second, … tenth
digits).
3. Add the results from step 1 and 2. If the last digit of the addition result is 0, then 0 is the
check digit. .
ontents
· Introduction
· Objectives
· Configuration
· Shapes
· Controls
· Sounds
· Scoring
· Code Requirements
· Report
· Deliverables
· Grading
· Start Small
Introduction
The Final Project gives you the opportunity to apply the object-oriented software development skills you have acquired during the course to a significant but moderately-sized application. The following sections describe the general behavior of the application, the simulation, and the deliverable requirements for the project.
The final project for this class is a built upon your homeworks. You are going to create a very simple version of Asteroids, but with shapes.
I will also work through this with you and provide you a working demo on D2L by end of week 8
The template for the project is on D2L under Final Project.
Objectives
The objective is pretty simple. Create a keyboard driven video game, with you the player in the center of the screen. Shapes will enter the screen and you will need to shoot them. If any of the shapes collide with your ship your game will end.
What I will provide:
A template GUI to start with.
Trapping the keys and bound methods for them. You can find this
Configuration
Configuration.json is the games overall configuration file. Since this is a first attempt at such a project we may need to add additional parameters. You can use the ShapeParser as an example of how to parse this file. I would recommend you add additional utility methods to the Extractor utility class if needed. You may want to consider a singleton that stores all the configuration data. It will help you not only with design but the ability to hardcode debug values in it instead of having to constantly modify the configuration.json. The configuration file contains only best guesses as to what values to put in. You should adjust them accordingly for development then pick ones that are realistic for final release. Hint: By having slow speeds you can easily validate your game visually.
Below are the fields:
“game”– The main key for the file. Not used for anything internally.
“framespersecond” – int - The number of framespersecond, or the overall game speed. Use this value in Motion.java. Replace the ‘FRAMES_PER_SECOND’ with a call to your Configuration managers method for framespersecond.
“shotspeed” – float - The speed at which your shots will travel. Shots are not affected by friction.
“forwardthrust” – float - Each tap of the forward thrust increases the player’s x/y speed by 1. Remember in graphics ‘up’ is –y. I will provide you with the algorithms for this. Basically if the nose of the ship is at 0 degrees it’s cos 0 degrees, sin 0 degrees or +1.0x, 0y. If it’s at 45degress, it’s 1/sqrt(2), -1/sqrt(2), and at 0 its 0,-1. Again remember for y it’s inverted. I will double check to make sure this works.
"shapes" – float - This is the num.
I have to write a Connect Four game program When a player t.pdfaayushmaany2k14
I have to write a Connect Four game program. When a player takes their turn, they will select a
column in which to place a token. The token is placed at the top of the column and is allowed to
fall to the bottom, stacking on top of any previously placed tokens. Two players take turns placing
token colors of red or yellow. The first person to create four of their color token in a row,
horizontally or vertically, (NOT diagonally in this problem) wins and the game is over.
The program will display the board (7 columns and 6 rows), then ask for alternating players to
place a token in column 0 through 6. The process repeats until one player wins. You do not need
to check for a tie game, or if there is space in a chosen column.
The photos (shown below) contain the code for the game framework. It is required that I utilize
functions and write my code within the functions. The function signatures are provided for you in
the framework. Examine each one to see what will be needed by the end. I am given 2 functions to
start with: main() and display(board).
Part 1: Fill out the code for the placeToken function. It is given three parameters: (1) the board,
(2) the column in which to place a token, and (3) the token itself. The board is the two dimensional
list of characters, with spaces ' ' being empty locations. The column is a numerical index in which
to place the token, and the token is the character 'R' or 'Y'.
Start at the top row (index 0) and move down the rows until the row below is not ' ', then place the
token. Then return the row the token ended up in. You can test this out by running the program,
but the game won't end yet because the other functions are incomplete. Use control+C (command
+ C) to stop the game early.
Another way to approach this is to start at the bottom row and walk upwards until the space is ' '.
Part 2: Fill out the code for the winningMove function. The game is won if four tokens of the
same color line up either vertically or horizontally. Good functional design would have these
checks in their own functions. Fill in the code for winningMove such that it uses the 2 other check
functions (below). This function can be one line of code. The row and column parameters are the
location of the last move taken.
Part 3: Fill in the code for checkVertical, which checks for four in a line vertically (on the same
column) as the given row and column parameters. You only need to search outward from the row
and column parameters and not the whole board. Since new moves are controlled by gravity in
connect four, you only need to search downward. You can test if this is working by running the
program.
Part 4: Fill in the code for checkHorizontal, which checks for four in a line horizontally (on the
same row) as the given row and column parameters. You only need to search outward from the
row and column parameters and not the whole board. You can test if this is working by running the
program.
The last photo shows an example run..
This is an individual project, to be completed on your own. It i.docxabhi353063
This is an
individual
project, to be completed on your own. It is considered dishonest either to read someone else's solution or to provide a classmate with a copy of your work. Do not make the mistake of thinking that superficial changes in a program (such as altering comments, changing variable names, or interchanging statements) can be used to avoid detection. If you cannot do the work yourself, it is extremely unlikely that you can succeed in disguising someone else's work. We are adamant that cheating in any form is not tolerated. Even the most trivial assignment is better not done than if you cheat to complete it.
Prerequisites
Primitive types
Conditionals
Loops
Arrays
Learning Objectives
Problem Solving
Traversing and manipulating 2-dimensional arrays
Using nested loops
Introduction
In this project, you will implement the logic of the game
Othello
, also known as
Reversi
.
Game Rules
Othello is a strategy board game for two players on a squared checkered board. It is played with identical disks that are white on one side and black on the other. Players take turns placing disks on the board with their assigned color facing up.
The game starts with four disks placed in a square at the center of the board in a standard diagonal pattern: two facing white side up, two facing black side up and same-colored disk on a diagonal with each other. These four initial disks are
not
placed by the player.
The black player moves first. He must place a disk with the black side up on the board, in such a position that there exists
at least
one straight occupied line between the new disk and another dark disk, with one or more contiguous white disks
bounded
between them. During a move, all bounded disks of the opponent's color are turned over to the current's player color. A straight line involves: horizontal, vertical and diagonal lines in every possible direction.
It is possible to bound disks in more than one direction during a single move.
Players take turns to play. When a player doesn't have any valid moves, his turned is skipped. The game must keep going while there are valid moves by either player. The goal of the game is to have the
majority of the disks displaying your color
when there are no more possible moves.
We suggest that you play
an online version of the game
to grasp the idea.
Your Task
In this project, you will implement the rules and logic for Othello. You are provided with the skeleton code containing the
basic methods
that you need to complete to launch this game on the java console.
You have the freedom to use additional methods and variables to structure your solution, as long as the basic methods behave as expected.
Implementation Details
This project consists of just one class:
Othello
: it implements the logic of the game. You will implement the missing methods.
You should begin coding
after you have read the entire handout, understood the problem and made a plan for solving it.
Variables
The
Othello
clas ...
I have another assignment due for an advance java programming class .pdfFORTUNE2505
I have another assignment due for an advance java programming class that I do not understand
how to do. I don\'t know how to implement the comparable interface and sort the cards from
lowest to highest based on suit within rank. And I also dont understand how I am suppose to add
a static nested class that implements the comparator interface and then sort the cards lowest to
highest based on rank within a suit. Then I have to add the different buttons and I am not sure
which class that these buttons are to be placed in. The buttons I have to add are: Deal Button,
Fish Sort Button, Spades Sort Button, and a Reverse Toggle Button. The description for each
button is in the instructions below:
Program 4 – Sorting with nested classes and lambda expressions
This program is a bit different from our others. Just like the last program, you will start with the
project that is attached to this assignment. Remember to rename the project. You will lose points
if you do not. Also, remember that you need to submit an Eclipse project, not just Java files. You
will lose points there as well.
The main point of the exercise is to demonstrate your ability to use various types of nested
classes. Of course, sorting is important as well, but you don’t really need to do much more than
create the class that does the comparison. In general, I like giving you some latitude in how you
design and implement your projects. However, for this assignment, each piece is very specific as
to how I want you to implement things. There are a number of parts to this program. Make
certain you accomplish the two additions to the Card class early-on since much of the rest of
your program will depend on that work.
The requirements:
Properly named project, good code (avoid redundancy), nice UI, etc. (20 pts)
Implement the Comparable interface in the Card class. (15 pts)
Sort the cards lowest to highest based on suit within rank, e.g.
2 clubs
2 diamonds
2 hearts
2 spades
3 clubs
3 diamonds
etc.
Add a static nested class to the Card class that implements the Comparator interface. (15 pts)
Sort the cards lowest to highest based on rank within suit, e.g.
2 clubs
3 clubs
4 clubs
5 clubs
etc.
In the UI, add the following to your interface.
Deal Button (10 pts)
Implement the Deal action handler using an inner class (not local). You may want to pull some
of the code from the show method that is already there. Or better, put the common code into a
class and call it.
Fish Sort Button (15 pts)
Sort the code in a way that would be useful playing Go Fish. I.e. with all of the cards grouped
together. Implement the action handler using a lambda expression in the UI. The code in the
lambda expression should depend on the Card class for the actual sorting (i.e. the natural order).
It must not call any other method in the UI class.
Spades Sort Button (15 pts)
Order the cards in such a way that they would be useful playing Spades; i.e. with the cards sorted
by rank within suit and the suits in the order pro.
Agent tic tac-toe - an interactive game for computational thinkingLorennRuster
Agent Tic-Tac-Toe is an interactive game that explains how a programmed agent plays tic-tac-toe, enabling computational thinking skills.
You are a spy (Agent Jamie Bond). Your mission is to play the next move in a game of tic-tac-toe following a set of instructions contained in a series of envelopes. You will record your findings as you go, in your Agent Report. At the end of the game, you will have made the next move.
For increased difficulty, the game can be played in interaction with another team. In this case, the game can be repeated until a winning move is made.
A complete set of resources including classroom materials, curriculum notes and teacher notes can be found in this document.
1. CSC-141 Introduction to Computer Programming Spring-2013
Assignment 2
CSC-141 Introduction to Computer Programming
Instructor: Saba Anwar
Class: FA12-BPH-A
Total Marks: 50
Assignment Date Saturday May 18, 2013
Submission Date and Time: Monday May 25, 2013 by 11:55 PM
Submission Guidelines:
This is an individual assignment. For collaboration rules, please consult academic rules /honor code
(placed at website).Your submitted work will be compared with that of your friends, and copied work will
lead you to strict penalty.
When you are done with both questions, place your name and roll number in comments at start of each
program. Save each file with filename of this pattern: FA12BPH-0XX-1.c and FA12-0XX-2.c. XX is your
ID and 1, 2 represent Task number.
Send both files in a single mail with subject FA12-BPH-A [Assignment1] to
ciitsubmissions@gmail.com
Any violation may misplace your assignment and you will be marked as “Absent” in assignment.
You may submit it late as well. 20% marks will be deducted for late submission of one day and 40%
marks will be deducted for late submission of two days. No assignment will be accepted after 48 hours.
__________________________________________________________________________________
Task 1
A possible 2D array is given below
You can see that its last cell is empty. Implement the following program:
Numbers should be displayed in the above fashion. Allow the user to hit any of the arrow
keys (up, down, left or right). If user hits up key, then the piece with number 4 and blank
piece will be swapped, and this table will look like:
2. CSC-141 Introduction to Computer Programming Spring-2013
After that if user hits left key, then the piece with number 43 and blank piece will be swapped
and table will look like:
If user hits left key and there is no column on left, then it should give appropriate message. With every
hit, it will check whether numbers are sorted in ascending order or not. When all 15 integers are sorted
and blank is at last position, then it should stop by giving success message, and this table will look like:
To keep track of keys, use getch() and identify each key by its ASCII codes as follows:
Up arrow key: 72
Down arrow key: 80
Right arrow key: 75
Left arrow key: 77
It should also show number of moves at each step. It may also be stopped by press ‘q’ somewhere to
quit the program.
Task 2
3. CSC-141 Introduction to Computer Programming Spring-2013
In this task you will be implementing a simple board game called Dungeon Crawl. It will use a simple 2D
string array to draw the game board. The board should be like following:
… P ………
…… E ……
…… E ……
……… E …
… E ………
……… E …
………… $
P is the player, E’s are enemies, and $ is the treasure. Objective of the game is to safely steal the hidden
treasure in the dungeon. Following are the rules of game
1. P can move in any direction but it should not go beyond the board boundary, if it goes he dies
and game will be lost.
2. If P collides with any enemy, its life points are decreased by 1. The total points are 3 at start.
Display life points along with board throughout the game.
3. Enemies can be placed anywhere on board randomly, every time game starts, But player’s
position can be fixed in 1st
row where ever you want. You can set number of enemies yourself,
but minimum they should be 5
Use arrows keys to move the player on board
Bonus point: you can move enemies in random directions with every move of player.
___________________________________________