Overview
This assignment is the second part of a two-week project that utilizes abstract classes, interfaces, and polymorphism to simulate an ecosystem of different organisms. Last week you created all of the plant and animal classes that will be present in the simulation. This week you will be creating the simulation program. Thanks to the groundwork that you created last week, we can use polymorphism to easily perform operations on all of our organism types. Additionally, we’ll be using ArrayLists to contain the constantly fluctuating number of organisms in our ecosystem.
The coding skills you will practice in this assignment include:
using polymorphism
downcasting objects to call their class methods
using ArrayLists
Instructions
Add a new static class called EnvironmentSimulation to the project that you started last week. This simulation will manage an ArrayList of Organisms – these are the plants and animals present in the ecosystem simulation. The simulation program must perform the following operations:
Have each Organism take their actions (do the following sub-steps in order for every Organism currently in the simulation)Have the Organism reproduce
If the Organism is an Animal:Check if it is hungry. If so, have it eat other valid living Organisms until it is no longer hungry
Expend energy (only once)
If the Organism is a Plant:Have the plant regenerate
Add newly born Organisms to the simulation
Remove dead Organisms from the simulation
Display the status of the simulation which includes for each Organism species:How many of that species were already alive
How many of that species were just born
How many of that species have just died
The new total number for that species
You must not modify anything in the classes you created last week! Assuming your classes from last week were created according to the instructions, all operations you need are already present as methods. You must create the simulation program without adding any new methods to any of the organism classes.
The simulation must perform all of these operations once and then ask the user if they want to continue the simulation or quit. If they choose to continue, all of these operations repeat from the beginning. Each repetition of the simulation is a simulation “step”.
Details of the Simulation
1. All plants and animals are stored in a single ArrayList of OrganismsYou must store all of your Organisms in a single ArrayList of type Organism. This is possible because all plant and animal classes are derived from the Organism abstract class. If you need to perform specialized actions on each of your creatures, you must first check that they are an instance of the desired child class of Organism, and then downcast them to the appropriate type.
2. Not all Organisms are added at once in the beginningInstead of adding all of the Organisms in the simulation at the beginning, you must add each species separately after different amounts of time have passed. This allows the prey populations to become established before the predators, which makes the simulation more interesting to watch.
5 Orange Trees and 30 Grass Patches are added at the very beginning of the simulation.
30 Squirrels are added on the fifth (5) simulation step.
50 Deer are added on the tenth (10) simulation step.
10 Wolves are added on the twentieth (20) simulation step.
No Oranges should be added manually – they should be exclusively produced by the Orange Trees
3. Dead Organisms still take their actionsThe simulation does not prevent dead Organisms from reproducing or taking actions. The individual steps of our simulation do not take time into account. If dead Organisms were prevented from taking actions, then Organisms earlier in the ArrayList would be given priority. By allowing dead organisms to take their actions as normal, every single Organism is given equal priority.
4. What Organisms count as prey?An Animal object can only eat another Organism if all of the following are true:
The Organism is an instance of type Edible.
The Organism is valid prey for this Animal (canEat())
The Organism is alive. Even though dead Organisms can take actions, they still can’t be chosen to be eaten.
5. Organisms that were just born are not added to the simulation until after all existing Organisms have already actedAny Organisms that were born during the current simulation step do not take any actions during the step in which they were born, and they cannot be targeted as prey. Newly born Organisms are only added to the ArrayList of Organisms after the step in which they were born. You may want to keep a second ArrayList for these newly born Organisms and only combine the two lists once the current iteration has ended.
Submission
Test your simulation thoroughly before submission! You are welcome to tweak the numbers in the simulation to produce different behavior for testing, but please revert them to the values provided for each class before submission.
Your submission must include the following:
The EnvironmentSimulation static class
A screenshot of the simulation program’s output at step 20
All plant and animal classes used in the simulation, which are:Three abstract classes: Organism, Animal, and Plant
The Edible interface
Three animal species classes: Squirrel, Deer, and Wolf
Three plant species classes: GrassPatch, Orange, and OrangeTree
For this assignment, please compress all of your files into a single zip file! Please only include your class files and screenshot in the zip file – do not include any other files from the Eclipse project.
To create a zip file:
Place all of your class files into a single folder on your computer.
For Windows computers, right click the folder and select “Send to > Compressed (zipped) folder” from the menu. For Mac computers, control-click the folder and select “Compress” from the menu.
A new .zip folder will be created with the same name as the original folder. This is the zip file that you submit.
When you have completed all of the files and compressed them into a zip file, submit the zip file by clicking “Start Assignment” at the top of the page and then selecting your file for submission. This assignment will only accept a .zip file; it will NOT accept an Eclipse project file or the files individually. No points will be awarded to programs that do not compile.
Rubric
Category: Java
Assignment scenario: Customer Management System(CMS): You are developing
Assignment scenario:
Customer Management System(CMS):
You are developing a simple CMS for a retail company. The system will allow the users to:
Retrieve customer details.
Add a new customer.
Update existing customer details.
Delete a customer.
The customer details are stored in a JSON file named “customer.json”.
The system contains the following components for above four operations as;
SOAP web services to retrieve, add, update and delete customer by admin.
RESTful web service to retrieve customer details by customer.
Implement the scenario in two phases as:
Phase 1: (user interface/client side)[20 Marks]
At phase 1, develop the client-side interface to ensure that SOAP services are accessed properly via a java application and RESTFul service is accessed via a web browser.
For admin [Access SOAP Services]:
After successful login the admin should be able to retrieve customer by customer id, add a new customer, delete a customer and update customer data. [15 marks]
For customer [Access REST service]:
After successful login, the customer should be able to see his/her details by retrieve customer using customer id.[5 marks]
Hint: Provide the necessary attributes and GUI interfaces and use the necessary communicating protocol.
Phase 2 (Server-side service) [40 Marks]
At phase 2, develop web services using the JAVA programming languages. For each task required in phase one, you should provide an appropriate service using JAVA and provide the required security for only RESTful service to grant access only to authorized users.
Here are some details regarding the functionality of some services:[10 marks each]
Retrieve customer: this service should retrieve customer details given customer id that exist in a file (JSON format) on the server side.
Add a new customer: this service should add new customer to the JSON file.
Update an existing customer: this service should update the customer details of a particular customer, modifying the JSON file accordingly.
Delete a customer: this service should allow admin to delete the customer details of particular customer.
Hint: Use the appropriate presentation format to save and read the necessary attributes to and from file.
Part 2 – Cloud Computing [40 marks]
Cloud Computing services include core services such as Compute Services, Storage Services, Networking Services and Database Services.
Write a brief report ‘Cloud Computing Services Comparison Report: AWS vs Azure’ to compare the services of both the Cloud service providers. The report must include the following sections
Executive Summary: [introduce cloud and purpose of report]. [5 marks]
Introduction: [overview and importance of cloud computing, background on AWS and Azure. comparison parameters – service offering, pricing, performance and security] [10 marks]
Core service comparison: [Compute Services, Storage Services, Networking Services and Database Services]. [15 marks]
Recommendation and Conclusion. [5 marks]
References. [5 marks]
Note: Use Harvard style of referencing to provide at least 3 references for part 2.
Instructions:
Submit two files One zip file for Part 1 of the TMA containing All the project’s folders, assuming that you are using NetBeans to develop your TMA, then you are required to send the whole project folder as a single zip file.
A word file that contains Phase 1 and Phase 2 codes of client side, the operations of the web services as well as screenshots after running each service [at least 4 screenshots that must show the admin operations and customer view by customer].
Needed xml files.
Word file for Part 2 of the TMA Report file in word.docx format
Use the following format to name your zip file:
TM352-TMA-SP-23_24-Branch-StudentFirstName-ID
Use the following format to name your word file:
TM352-TMA-SP-23_24-Branch-StudentFirstName-ID.docx
UML class diagram I want to make a UML class diagram I have a ready one that nee
UML class diagram I want to make a UML class diagram I have a ready one that needs an add on the classes I will provide the code file with everything , check the class diagram if it has any flaw. just do the one on the right that has the admin, articles, etc
We will be practicing basic class inheritance in our lab for this week. You are
We will be practicing basic class inheritance in our lab for this week. You are going to create a simple hierarchy of classes based on shapes.
In addition to practicing basic inheritance, we will also be looking at elements that are commonly included in derived classes, such as super constructors, the protected access modifier, and method overriding. The goal for this lab is to recognize the power of class inheritance and its ability to create complex object types with simple instructions.
Construct the lab file by following the instructions below. The check-in for the lab this Friday will be for parts 1 and 2 below. Once you have completed the program, you will submit it for this assignment.
Part 1: Animal Class Hierarchy
Imagine you wanted to create a program for a zoo that contained a class for each type of animal the zoo could contain. This wouldn’t just be for generic types of animals, but for specific species of animal such as brown bear, polar bear, black bear, panda bear, etc. That would be a lot of classes! More importantly than that, many of those classes would have very similar functionality – each of the bear classes are probably very similar to one another. This quickly turns into a headache of having to copy and paste redundant code many times – and worse, if you need to make a change to the bears later then you have to go back and change every single bear class.
This is the very problem that class inheritance was designed to solve. We can make one class that contains functionality that should be shared by other classes, and then we can have all of those classes “inherit” that code directly from the shared file. For this program, we are going to define a suite of short classes for different animals and use inheritance to save us the trouble of writing redundant code.
Follow along with the video to construct the classes that you will need for this lab. The code for the classes created in the video is provided below, but you are encouraged to follow along and create them yourself for practice. After you have finished watching the video, continue with the instructions below.
Files from the video:
Once you have been introduced to the lab concept from the video, proceed with the following.
Create two new animal classes that fit into this existing project. You can extend the classes that are already there to create specific species of animals, or you can define new classifications such as Mammal or Reptile. These two classes must adhere to the following rules:
All classes must directly or indirectly inherit from the Animal class.
The classes you create must inherit from the existing classes in a logical way: for example, do not create an Eagle class and have it inherit from Fish.
Each class you create must contain a new variable that is not inherited from other classes, as well as some kind of accessor/mutator methods for that variable.
The constructors for the classes you create must set the variables appropriately. You may hard-code in values like the video showed.
You must override the makeNoise method for each class you create if it makes sense to.
Part 2: UML Class Diagram
The zoo project in part 1 is made up of a lot of different classes with their own methods and classes. To prevent this project from becoming too complicated, we will create a UML class diagram to model each class and their relationships to one another.
Create a UML class diagram for all of the classes from part 1 (including the two you designed yourself) showing the full details of each class’s members and their inheritance relationships.
Modeling inheritance on a UML class diagram is relatively easy and only involves a few extra details that weren’t covered in the original UML chapter:
Inheritance relationships are shown as a solid line with an empty/white arrow pointing to the parent class. The convention is to always have the parent class above its child classes so that inheritance relationships are shown vertically. Inheritance relationship lines don’t need role descriptions or multiplicity values.
Class members with protected access use the symbol # (instead of + for public or – for private).
If a variable or method is inherited directly by a child class, then it does not need to be included in the child class’s box. The inheritance of those class members is implied by the relationship arrow.
If a child class overrides a method from a parent class, then that method must be included in the child class’s box. You can tell that it’s an overridden method and not just an inherited one because the same method appears in both the child and parent classes.
This is the minimum amount of progress on the program that is required for this week’s check-in. Please make your check-in post now before continuing with the remainder of the lab. Please remember to make the check-in post before the deadline.
Part 3: Geometric Shapes
Another great demonstration of inheritance is in the types of geometric shapes. There are different classifications for the various 2D shapes in mathematics, but certain classifications are just more specific versions of others.
For this part of the lab you will be creating a suite of short classes for a variety of geometric 2D shapes:
Polygon: any 2D shape made up of any number of straight sidesTriangle: any polygon with exactly 3 sides
Quadrilateral: any polygon with exactly 4 sidesParallelogram: any quadrilateral where opposite sides are equal lengthRhombus: any parallelogram where all sides are the same length
Rectangle: any parallelogram where the interior angles of the shape are all 90 degreesSquare: any rectangle where all sides are the same length
(Note: you can also define a square as a rhombus where the interior angles are all 90 degrees)
The video below explains the relationships between the shapes
For this part of the lab, follow the instructions below to create the shape classes that inherit from one another.
Polygon
The Polygon class needs to be able to keep track of a shape with any number of sides. Since this is also the root class that all of our other classes will inherit from, it is also going to contain a little bit of functionality that all shape classes should share.
Add the following variable and methods to the Polygon class.
protected int[] sidesThe array that represents the sides of the shape. Each integer in the array is the length of one side. This array should not have a default length! Polygons can have any number of sides, so the array should be custom-made for each polygon for its needs.
public Polygon(int[] sides)The constructor for a Polygon. It should just set the sides variable to the array parameter.
public int findPerimeter()Returns the perimeter of the polygon. This is the sum of the lengths of all sides.
Triangle
The triangle class inherits from Polygon. This class should only contain the constructor for Triangles.
The constructor should be made in such a way that it prevents Triangles from having anything other than 3 sides. This constructor needs to call the Polygon super constructor, but that does not mean that this constructor needs to be the same as the super constructor. Copy the constructor below into Triangle.
public Triangle(int side1, int side2, int side3) {
super(new int[3]);
sides[0] = side1;
sides[1] = side2;
sides[2] = side3;
}This constructor first passes an empty array of length 3 to the super constructor. This constructs a Polygon of 3 sides, which is what a Triangle is. Then we set the lengths of the 3 sides based on the parameters.
Quadrilateral
The Quadrilateral class also inherits from Polygon. This class should also only contain a constructor.
Define the Quadrilateral constructor in the same manner as the Triangle constructor, except for 4 sides instead of 3. This way we know that all Quadrilaterals and any classes that inherit from Quadrilateral always have exactly 4 sides.
Parallelogram
The Parallelogram class inherits from Quadrilateral. This class needs to modify the constructor even further to enforce the rule that opposite sides of a parallelogram are always equal length. It is also going to add some new functionality that will be useful for any derived classes.
Add the following variable and methods to the Parallelogram class:
int interiorAngle;The measurement of one interior angle of the Parallelogram, in degrees. The way Quadrilaterals are defined, there are always two pairs of equal angles in the Quadrilateral. This means we’re missing the measurement of the other angle, but thankfully we can calculate it on the fly: it will always be 180 minus our other angle.
public Parallelogram(int side1, int side2, int angle)The constructor for Parallelograms. Since opposite sides of parallelograms are always equal, we only need two side measurements. But the super constructor requires 4 sides, so what do we do? We can pass in the side measurements as pairs like this:
super(side1, side2, side1, side2);
This ensures that our four sides are always two pairs of equal sides. Also don’t forget to set the lengths of the sides and the interiorAngle variable!
public void printArea()This method prints out the area of the Parallelogram. Copy the following code for this method:
double area = sides[0] * sides[1] * Math.sin(Math.toRadians(interiorAngle));System.out.println(“Area is ” + area + “; found using Parallelogram’s method”);
You find the area of a parallelogram by multiplying the two side lengths by the sine of any interior angle (hence why we need to store the interior angle as a variable). We’ve stored the interior angle in degrees, but the sin method uses radians, so we’ll have to convert the number using the toRadians method first. We state that we’re using Parallelogram’s method for the printing because we’re planning on overwriting it in a derived class, and we want to see which class’s method is being called.
Rhombus
The Rhombus class inherits from Parallelogram. This class should only contain a constructor.
The Rhombus constructor should look like this:
public Rhombus(int side, int angle) {
super(side, side, angle);
}This is the same principle we used in Parallelogram to force opposite sides to be equal. Since all sides on a rhombus are equal, we only need one side measurement. We then pass it to both parameters of the super constructor, which is for Parallelogram (we also pass the angle so it is set correctly in that constructor). The Parallelogram class then turns those two equal side measurements into four equal side measurements for Quadrilateral, which in turn creates the array and sends it to Polygon. All of this together means that for very little code we can ensure that all Rhombuses always have 4 equal sides.
Rectangle
The Rectangle class inherits from Parallelogram. This class should contain a constructor, and it should override the printArea method that it inherits from Parallelogram.
The constructor should only take 2 side length parameters. When it calls the super constructor, it should pass those two parameters and then the number 90. By hard-coding in the number 90, we ensure that when the super constructor (Parallelogram’s) is called, the interiorAngle variable is always set to 90. That way we enforce the rule that rectangles are like parallelograms but with a 90 degree interior angle.
We are also going to override the printArea method in this class. The parallelogram’s area calculation will work for rectangles, but it is inefficient – to find the area of a rectangle we just need to multiply the two sides together (we can exclude the sine). The overridden method should look like this:
@Override
public void printArea() {
double area = sides[0] * sides[1];
System.out.println(“Area is ” + area + “; found using Rectangle’s method”);
}We also specify which class’s method we are using here. Now whenever we call the printArea method we know which class is providing the calculations, Parallelogram or Rectangle.
Square
The Square class inherits from Rectangle (it could also inherit from Rhombus, but Rectangle is easier for this program). This class should only contain a constructor.
Create the Square class’s constructor in the same manner as the Rhombus constructor, except without specifying the interior angle. It should only have one parameter: the side length.
Although our constructors started with many parameters, we have now narrowed it down to 1. Each constructor only takes the parameters it needs and manipulates the super constructors into creating the rest of the information necessary for that shape. Squares take one side length (since all of their sides are equal). The super constructor, Rectangle, takes that side length twice to use for its pairs of equal sides. The next super constructor, Parallelogram, takes those two side pair lengths and also an interior angle measurement that Rectangle always provides as 90. This goes to the next super constructor, Quadrilateral, which takes four side lengths, the two side pair lengths of Parallelogram doubled (which means Square’s original side length has now been duplicated to all 4 sides). Finally, the super constructor for Polygon is called and passed an array of length 4, which is filled inside of Quadrilateral.
Main Method
Create a main method inside of the Parallelogram class with the following code:
Create a Rhombus with side length 2 and any angle.
Call the printArea method on the Rhombus.
Create a Square with side length 4.
Call the printArea method on the Square.
After you create the main method, run the program and take a screenshot of the main method’s output.
Submission
For this lab you will be submitting 3 files:
The UML class diagram created in part 2 for the zoo classes
The Parallelogram.java class file from part 3, which also contains the code for the main method
The screenshot of your program’s output after running the main method from part 3
Submit your files by clicking “Start Assignment” at the top of the page and then selecting your files for submission. You can submit all files by selecting “Add Another File” in the submission box. Please submit all files individually; this assignment will NOT accept a zip file or an Eclipse project.
Proper referencing in APA format is must Text size 12-Times New Roman only. Avoi
Proper referencing in APA format is must
Text size 12-Times New Roman only.
Avoid plagiarism
You must give 100/100 correct solutions
Avoid using paraphrasing programs or websites
You must provide a correct answer 100/100
You must do the solution in the same attached file
You must do the solution in the same attached file
You must provide the solution within1 hour only from the time you accept the request and do not wait until the time specified on the site
Codes must be written in text and images
If personal information is required, use the attached information
You should avoid plagiarism from any website or artificial intelligence
You must provide the solution within two hours only from the time you accept the request and do not wait until the time specified on the site
Proper referencing in APA format is must
Text size 12-Times New Roman only.
Avoid plagiarisms
Avoid copying from any source
Avoid using another teacher’s solution or a similar previous student’s solution because it is a university whose system can access even the solutions published on the study pool website
You must give 100/100 correct solution
Avoid using paraphrasing programs or websites
You must provide a correct answer 100/100
You must do the solution in the same attached file
You must do the solution in the same attached file
ATTACHMENTS
We will be practicing creating and interpreting UML class diagrams for our lab t
We will be practicing creating and interpreting UML class diagrams for our lab this week.
UML class diagrams are an industry standard way of designing object-oriented programs. Being able to efficiently create accurate class diagrams will allow you to easily design large, complex programs. The better your initial design is, the better the final product will be. The goal for this lab is to practice using UML class diagrams enough to recognize all of the different symbols and arrows used.
Construct the lab files by following the instructions below. The check-in for the lab this Friday will be for all parts below. Once you have completed the program, you will submit it for this assignment.
Part 1: UML to Java
For the first half of this lab, you will be implementing an existing UML class diagram as a set of Java program files.
Create a Java class file for the King, Knight, Weapon, and Material classes shown in the UML class diagram below. Your classes must implement everything shown in the diagram, including all variables with correct access modifiers, methods, and inheritance. Notes about the diagram are provided below.
Diagram Notes
Access ModifiersMake sure you use the correct access modifiers for the variables and methods in this diagram. The symbols for all three modifiers are shown: + for public, – for private, and # for protected.
Method BodiesEvery method in this diagram is either a constructor, an accessor, or a mutator (equipWeapon and reforge are mutators).
The details of how each method should be filled out aren’t provided on UML class diagrams, so in a practical scenario you would need to have separate documentation to keep track of this. For this lab the methods are all relatively simple.
Relationship Between King and KnightThe relationship between King and Knight is association. This is shown using a plain line with no arrow or diamond. A King can have any number of Knights under his command, but each Knight must have one and only one King.
This relationship is useful for keeping track of the purpose of these classes, but it does not have any impact on the code for this lab. In a more fleshed-out project, this relationship would be enforced somewhere else in the code, in the methods of Knight and King or in another class entirely.
Relationship Between Knight and WeaponThe relationship between Knight and Weapon is aggregation. This is shown using a line with an empty/white diamond on the aggregator. A Knight must always have a Weapon (and in this case, no more than one at a time). In contrast, a Weapon can be wielded by a maximum of one Knight at a time, but it might also be ownerless.
Aggregation relationships demonstrate that one class contains another. In this case, Knight contains Weapon. This is implemented in the code by giving the Knight class a Weapon variable called arms (short for armaments). Since the relationship shown is aggregation, this means a Weapon can exist separate from the Knight class. We can also see this in the multiplicity values; a Weapon can be wielded by 0 or 1 Knights.
Relationship between Weapon and MaterialThe relationship between Weapon and Material is composition. This is shown using a line with a filled/black diamond on the composite class. A weapon must always be made of a material, and (in this program) a material is only ever used to construct one weapon.
Composition relationships are like aggregation relationships in that one class contains another, but they differ in that the contained class cannot exist outside of the container. In the project outlined by this diagram, a Material cannot exist separately from a Weapon. It is created alongside the Weapon, and it is destroyed alongside it as well. Every Material must always belong to exactly one Weapon – no more, no less.
One easily missed detail about this relationship in the diagram above is the getMaterial method of Weapon. It returns a String, the name of the material, instead of the Material object itself. This way the reference to the Material object can’t be accessed or taken outside of the Weapon class (it still must be created outside of the class for the constructor though).
Part 2: Java to UML
For the second half of this lab, you will be documenting an existing Java project as a UML class diagram.
Download and extract the zip file below. Create a UML class diagram containing all of the classes in the zip file. Your diagram must show all details that are in the class files, including all variables, methods, access modifiers, inheritance relationships, and non-inheritance relationships. Notes about the classes are provided below.
You may draw your diagram by hand and submit a picture of it, or you may use any digital drawing software of your choice. You are allowed to use a program that is made specifically for UML diagram creation such as LucidChart (there is a free version available). If you are uncertain whether or not you are allowed to use any given software for this assignment, please send me a message with the name of the software you would like to use and I will see if it is acceptable.
This project models board games and card games. The classes include: BoardGame.java, CardGame.java, Player.java, CardPlayer.java, Card.java, CardDeck.java, Die.java, and Color.java.
Class files for this part:
You can extract a zip file on Windows by right clicking the zip file and selecting “Extract All”, then selecting a destination for the unzipped files (the default location is in a folder with the same name as the zip file, in the same location as the zip file).
You can extract a zip file on Mac just by double clicking it. The unzipped file will be in the same location that the zipped file was.
Notes about the Classes
The Inheritance RelationshipsThis project gives us a sneak peek at a future topic this semester: class inheritance. The CardGame class inherits from the BoardGame class, and the CardPlayer class inherits from the Player class. In the code, you can see this by the use of the “extends” keyword in the class headers.
In UML diagrams, standard inheritance relationships are shown using an empty/white arrow pointing to the “parent” class. These connections should not have role descriptions or multiplicity values. Other than this new type of arrow, nothing else needs to be changed about the classes, and they can all still have other relationships to them as normal. Here is an example of what those connections should look like in your diagram (your diagram should not have the text hint in the middle).
We will revisit this syntax when we cover inheritance relationships.
Static and Constant VariablesUML class diagrams are created to show the relationships between classes in an object-oriented program. Static and constant fields are separate from objects created from the classes, so they are often left out of class diagrams. Please include all static fields and constants for this assignment.
Since these elements are often excluded, the syntax for how to specify them isn’t always consistent. You may write your static and constant class members the same way that you would write non-static and non-constant members, or you may use the following syntax.
For static members: underline them.
For constants: write them the same as variables, but include the value of the constants. For example “+PI: double = 3.14”.
The Non-Inheritance RelationshipsMost of the relationships in this project are either aggregation or composition. The difference between the two is whether the class that is contained in the other continues to exist when the container class is destroyed.
It is best to analyze the code for this, but you can also try to apply some common sense logic. A few examples include:
Does a card continue to exist when its deck is destroyed?
Do the Player objects continue to exist when the BoardGame object is destroyed? (Don’t think of the Player objects as people – they are just collections of board game information, like the player’s score. Does it make sense for a player to take their score from one game and keep it when playing a different one?)
If a card is held by a Player, does it still exist even if that Player is no longer part of the game?
ArrayList in CardPlayerThe CardPlayer class contains an ArrayList as one of its variables. We haven’t covered ArrayLists in-depth yet, but in simple terms they are arrays that can change length as needed whenever new items are added. In your diagram, the type of the CardPlayer’s hand variable needs to use the full type shown: “ArrayList
This is the minimum amount of progress that is required for this week’s check-in. Please make your check-in post with your completed diagram for part 2. Please remember to make the check-in post before the deadline. If no revisions are necessary with your check-in post, then that means you are done with this lab and ready to submit.
Submission
For this lab you will be submitting 5 files:
The four class files you created for part 1 of the lab
The picture or screenshot of your UML class diagram you created for part 2 of the lab
Submit your files by clicking “Start Assignment” at the top of the page and then selecting your screenshot and class files for submission. You can submit all files by selecting “Add Another File” in the submission box. Please submit all files individually; this assignment will NOT accept a zip file or an Eclipse project.
Rubric
CriteriaRatingsPts
This criterion is linked to a Learning OutcomePart 1 Class MembersFor full points, the variable names and types, and the method names, parameter names and types, and return types, as well as all access modifier symbols must be correct for all 5 classes.
The goal of these discussions is to give you more practice with the concepts bef
The goal of these discussions is to give you more practice with the concepts before you have to apply them in a real program. The discussions are a collaborative learning effort – you can work with others to come up with the answers, read your classmates’ posts to get feedback, and figure out the right answers as a class!
Directions
Read the prompt below and make a post containing your response. After you’ve made your first post you will be able to see everyone else’s posts. Use this opportunity to see what everyone else has come up with. You can continue to post, reply, and collaborate until you are satisfied with your answers. If you choose to work in a group, each person must still make their own individual posts.
Before the assignment’s due date, please reply to at least one other person’s post. The details for your reply to this week’s discussion are described in the prompt below. You’re more than welcome to make more than one reply and have discussions!
Click the three dots in the top right of this discussion assignment and select “Show Rubric” to see how points are awarded for this assignment.
Prompt
For your post, create a UML diagram for a single class of your choosing. Your class must contain at least one variable and at least 3 methods. You only need to create the specification for a single class and the variables methods inside of it – you don’t need to add any other classes or class relationships yet. Make sure you use the correct UML syntax when creating your class.
You may draw your diagram by hand and post a picture of it, or you may use any digital drawing software of your choice. You are allowed to use a program that is made specifically for UML diagram creation such as LucidChart (there is a free version available). If you are uncertain whether or not you are allowed to use any given software for this assignment, please send me a message with the name of the software you would like to use and I will see if it is acceptable.
You can post your class specification as a picture by selecting “Insert > Image > Upload Image” in the toolbar above the reply window.
Reply
For your reply this week, pick one of your classmates’ diagrams and add another class to it with some kind of relationship to the first class. Your new class must have at least one variable and at least one method, and you must show the relationship between the original class and your newly added class.
You are allowed to make a single change to the original class to fit the relationship you are going for. For example, if the original post contained a class called “Car”, you can design a class called “Tire” and modify the original car class to contain an array of Tire objects.
You are allowed to add another class to someone’s reply that already has more than one class in it, but the class that you add must still have at least one relationship to one of the existing classes. You may not add on to your own post.
You can choose any relationship between the two classes as long as it makes logical sense and is shown correctly. All relationships must show multiplicity values and descriptions for the two sides of the connections.
We will be practicing creating and interpreting UML class diagrams for our lab t
We will be practicing creating and interpreting UML class diagrams for our lab this week.
UML class diagrams are an industry standard way of designing object-oriented programs. Being able to efficiently create accurate class diagrams will allow you to easily design large, complex programs. The better your initial design is, the better the final product will be. The goal for this lab is to practice using UML class diagrams enough to recognize all of the different symbols and arrows used.
Construct the lab files by following the instructions below. The check-in for the lab this Friday will be for all parts below. Once you have completed the program, you will submit it for this assignment.
Part 1: UML to Java
For the first half of this lab, you will be implementing an existing UML class diagram as a set of Java program files.
Create a Java class file for the King, Knight, Weapon, Sword, and Lance classes shown in the UML class diagram below. Your classes must implement everything shown in the diagram, including all variables with correct access modifiers, methods, and inheritance. Notes about the diagram are provided below.
Diagram Notes
Access ModifiersMake sure you use the correct access modifiers for the variables and methods in this diagram. The symbols for all three modifiers are shown: + for public, – for private, and # for protected.
Method BodiesEvery method in this diagram is either a constructor, an accessor, or a mutator (equipWeapon and reforge are mutators).
The details of how each method should be filled out aren’t provided on UML class diagrams, so in a practical scenario you would need to have separate documentation to keep track of this. For this lab the methods are all relatively simple.
Relationship Between King and KnightThe relationship between King and Knight is association. This is shown using a plain line with no arrow or diamond. A King can have any number of Knights under his command, but each Knight must have one and only one King.
This relationship is useful for keeping track of the purpose of these classes, but it does not have any impact on the code for this lab. In a more fleshed-out project, this relationship would be enforced somewhere else in the code, in the methods of Knight and King or in another class entirely.
Relationship Between Knight and WeaponThe relationship between Knight and Weapon is aggregation. This is shown using a line with an empty/white diamond on the aggregator. A Knight must always have a Weapon (and in this case, no more than one at a time). In contrast, a Weapon can be wielded by a maximum of one Knight at a time, but it might also be ownerless.
Aggregation relationships demonstrate that one class contains another. In this case, Knight contains Weapon. This is implemented in the code by giving the Knight class a Weapon variable called arms (short for armaments). Since the relationship shown is aggregation, this means a Weapon can exist separate from the Knight class. We can also see this in the multiplicity values; a Weapon can be wielded by 0 or 1 Knights.
Relationship between Weapon and MaterialThe relationship between Weapon and Material is composition. This is shown using a line with a filled/black diamond on the composite class. A weapon must always be made of a material, and (in this program) a material is only ever used to construct one weapon.
Composition relationships are like aggregation relationships in that one class contains another, but they differ in that the contained class cannot exist outside of the container. In the project outlined by this diagram, a Material cannot exist separately from a Weapon. It is created alongside the Weapon, and it is destroyed alongside it as well. Every Material must always belong to exactly one Weapon – no more, no less.
One easily missed detail about this relationship in the diagram above is the getMaterial method of Weapon. It returns a String, the name of the material, instead of the Material object itself. This way the reference to the Material object can’t be accessed or taken outside of the Weapon class (it still must be created outside of the class for the constructor though).
Part 2: Java to UML
For the second half of this lab, you will be documenting an existing Java project as a UML class diagram.
Download and extract the zip file below. Create a UML class diagram containing all of the classes in the zip file. Your diagram must show all details that are in the class files, including all variables, methods, access modifiers, inheritance relationships, and non-inheritance relationships. Notes about the classes are provided below.
You may draw your diagram by hand and submit a picture of it, or you may use any digital drawing software of your choice. You are allowed to use a program that is made specifically for UML diagram creation such as LucidChartLinks to an external site. (there is a free version available). If you are uncertain whether or not you are allowed to use any given software for this assignment, please send me a message with the name of the software you would like to use and I will see if it is acceptable.
This project models board games and card games. The classes include: BoardGame.java, CardGame.java, Player.java, CardPlayer.java, Card.java, CardDeck.java, Die.java, and Color.java.
Class files for this part: Lab7Files.zipDownload Lab7Files.zip
You can extract a zip file on Windows by right clicking the zip file and selecting “Extract All”, then selecting a destination for the unzipped files (the default location is in a folder with the same name as the zip file, in the same location as the zip file).
You can extract a zip file on Mac just by double clicking it. The unzipped file will be in the same location that the zipped file was.
Notes about the Classes
The Inheritance RelationshipsThis project gives us a sneak peek at a future topic this semester: class inheritance. The CardGame class inherits from the BoardGame class, and the CardPlayer class inherits from the Player class. In the code, you can see this by the use of the “extends” keyword in the class headers.
In UML diagrams, standard inheritance relationships are shown using an empty/white arrow pointing to the “parent” class. These connections should not have role descriptions or multiplicity values. Other than this new type of arrow, nothing else needs to be changed about the classes, and they can all still have other relationships to them as normal. Here is an example of what those connections should look like in your diagram (your diagram should not have the text hint in the middle).
We will revisit this syntax when we cover inheritance relationships.
Static and Constant VariablesUML class diagrams are created to show the relationships between classes in an object-oriented program. Static and constant fields are separate from objects created from the classes, so they are often left out of class diagrams. Please include all static fields and constants for this assignment.
Since these elements are often excluded, the syntax for how to specify them isn’t always consistent. You may write your static and constant class members the same way that you would write non-static and non-constant members, or you may use the following syntax.
For static members: underline them.
For constants: write them the same as variables, but include the value of the constants. For example “+PI: double = 3.14”.
The Non-Inheritance RelationshipsMost of the relationships in this project are either aggregation or composition. The difference between the two is whether the class that is contained in the other continues to exist when the container class is destroyed.
It is best to analyze the code for this, but you can also try to apply some common sense logic. A few examples include:
Does a card continue to exist when its deck is destroyed?
Do the Player objects continue to exist when the BoardGame object is destroyed? (Don’t think of the Player objects as people – they are just collections of board game information, like the player’s score. Does it make sense for a player to take their score from one game and keep it when playing a different one?)
If a card is held by a Player, does it still exist even if that Player is no longer part of the game?
ArrayList in CardPlayerThe CardPlayer class contains an ArrayList as one of its variables. We haven’t covered ArrayLists in-depth yet, but in simple terms they are arrays that can change length as needed whenever new items are added. In your diagram, the type of the CardPlayer’s hand variable needs to use the full type shown: “ArrayList
This is the minimum amount of progress that is required for this week’s check-in. Please make your check-in post with your completed diagram for part 2. Please remember to make the check-in post before the deadline. If no revisions are necessary with your check-in post, then that means you are done with this lab and ready to submit.
Submission
For this lab you will be submitting 5 files:
The four class files you created for part 1 of the lab
The picture or screenshot of your UML class diagram you created for part 2 of the lab
Submit your files by clicking “Start Assignment” at the top of the page and then selecting your screenshot and class files for submission. You can submit all files by selecting “Add Another File” in the submission box. Please submit all files individually; this assignment will NOT accept a zip file or an Eclipse project.
CriteriaRatingsPts
This criterion is linked to a Learning OutcomePart 1 Class MembersFor full points, the variable names and types, and the method names, parameter names and types, and return types, as well as all access modifier symbols must be correct for all 5 classes.
You must submit two separate copies (one Word file and one PDF file) using the A
You must submit two separate copies (one Word file and one PDF file) using the Assignment Template on Blackboard via the allocated folder. These files must not be in compressed format.
It is your responsibility to check and make sure that you have uploaded both the correct files.
Zero mark will be given if you try to bypass the SafeAssign (e.g. misspell words, remove spaces between words, hide characters, use different character sets, convert text into image or languages other than English or any kind of manipulation).
Email submission will not be accepted.
You are advised to make your work clear and well-presented. This includes filling your information on the cover page.
You must use this template, failing which will result in zero mark.
You MUST show all your work, and text must not be converted into an image, unless specified otherwise by the question.
Late submission will result in ZERO mark.
The work should be your own, copying from students or other resources will result in ZERO mark.
Use Times New Roman font for all your answers. Question One
Write a Java program that demonstrates the use of the pre-increment operator (++i). In your program, you should:1. Define an integer variable i and initialize it to 5.2. Use the pre-increment operator to increment i before using it in this arithmetic expression (pre-increment operator + 10).3. Define an integer variable result to hold the result of arithmetic expression.4. Print the value of i after the increment.5. Print the result of the arithmetic expression where i is incremented using the pre-increment operator.6. Note: you must take a screenshot of the output Sample of the run: Question Two
Compare between high-level language and low-level language with an example. A. DefinitionsB. Examples Question Three
Write a program that asks for the user’s student name, student ID, and college name and prints a welcome message for the student. You must enter your real information. Here is a sample run of the program: Sample: Enter Student first name: AhmadEnter Student second name: Ali Enter Student ID :1234567Enter collage name: College of Computing and Informatics Welcome Ahmad Ali in the College of Computing and In
Proper referencing in APA format is must Text size 12-Times New Roman only. Avoi
Proper referencing in APA format is must
Text size 12-Times New Roman only.
Avoid plagiarism
You must give 100/100 correct solutions
Avoid using paraphrasing programs or websites
You must provide a correct answer 100/100
You must do the solution in the same attached file
You must do the solution in the same attached file
You must provide the solution within1 hour only from the time you accept the request and do not wait until the time specified on the site
Codes must be written in text and images
If personal information is required, use the attached information
You should avoid plagiarism from any website or artificial intelligence
You must provide the solution within two hours only from the time you accept the request and do not wait until the time specified on the site
Proper referencing in APA format is must
Text size 12-Times New Roman only.
Avoid plagiarisms
Avoid copying from any source
Avoid using another teacher’s solution or a similar previous student’s solution because it is a university whose system can access even the solutions published on the study pool website
You must give 100/100 correct solution
Avoid using paraphrasing programs or websites
You must provide a correct answer 100/100
You must do the solution in the same attached file
You must do the solution in the same attached file
ATTACHMENTS