Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java programming question Create three classes to simulate cheese connoisseurs. One class representing the cheese (Cheese.java), one class representing the cheese connoisseurs (CheeseConnoisseur.java), and one

Java programming question

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Create three classes to simulate cheese connoisseurs. One class representing the cheese (Cheese.java), one class representing the cheese connoisseurs (CheeseConnoisseur.java), and one class to run the simulation (Cheese Driver.java). Make sure to javadoc your code! There is no output for this program. Some restrictions - No imports are allowed. - Make sure to not use the following. var (the reserved keyword) System.exit Runtime.getRuntime.halt Runtime.getRuntime.exit Cheese.java File that represents some cheese from a grocery store. Once a cheese has been traded 3 times, it becomes sentient (becomes alive!). Instance Variables Pick appropriate variable types and names. All fields should follow the rules of encapsulation. - Holds the type of the cheese (such as Pepperjack, Cheddar) - Holds the price of the cheese - Holds whether or not this cheese is sentient - Holds a counter of how many times this specific Cheese object has been traded. - Holds how many cheese trades have happened across all cheeses * This variable should be the same across all instances of Cheese Constructors - A constructor that takes in the price, type, and number of trades for that specific Cheese instance. * A cheese should not be sentient at instantiation unless it has already been traded 3 times. - A constructor that takes in price, type. * A cheese should not be sentient at instantiation. * By default, a Cheese object has been traded 0 times. Methods - A toString method that converts a Cheese object to a String * If the cheese is not sentient, the String should be: "This is a slice of type) cheese that has been traded (number of trades) times. * If the cheese is sentient, the String should be: I am a slice of type) cheese that has been traded (number of trades] times. - An equals method (as learned in class) dependent on type, price, and sentience. * We're looking for an overloaded equals method here, not an overridden Object equals method. - A method for when a cheese is traded * Increment the appropriate variables * A cheese is sentient if it has been traded at least 3 times. When cheese becomes sentient, it doubles in price. . When cheese becomes sentient, it should print "I'm ALIIIIIVE! - getters/setters as needed CheeseConnoisseur.java File that represents a cheese connoisseur who owns a singular cheese. Instance Variables Pick appropriate variable types and names. All fields should follow the rules of encapsulation. - Holds the name of the connoisseur. - Holds one cheese owned by the connoisseur. - Holds how much money the connoisseur has. Constructors - One constructor that takes in name, money, and cheese - One constructor that takes in name, money * Should give the connoisseur a null Cheese that can be filled later. * This should use constructor chaining. - One constructor taking name. * The connoisseur should have no money. * The connoisseur should have no cheese at the moment. * This should use constructor chaining. - One constructor with no arguments. * The connoisseur's name should be "Louis Pasteur" * The connoisseur should own no cheese at the moment. * The connoisseur should have $20.00 Methods - One method that allows a CheeseConnoisseur to make a trade. It will take in a Cheese object. * The connoisseur should replace their current cheese with the cheese that is passed in to the method. * Both cheese trade variables should increase by 1 (instance and object) * If a cheese has been traded 3 times, it should become sentient. - Another method that allows a CheeseConnoisseur to make a trade. It will take in a CheeseConnoisseur. This method should overload the previous method. * If one of the cheese connoisseurs has a null cheese, the trade will not happen. * If the two cheeses are equal, the connoisseurs do not trade Cheese objects. * If they are not equal, the connoisseur who gives away the less expensive cheese should pay the difference, then they trade cheese. If they do not have enough money to pay the difference, the connoisseurs will not trade Cheese objects. Both cheese trade variables should increase by 1 (instance and object). If a cheese has been traded 3 times, it should become sentient. - Getters/setters as needed Cheese Driver.java A driver file that will run the simulation. Make sure to have the following in your Cheese Driver: Create at least 4 Cheese objects Create at least 2 CheeseConnoisseur objects. - One of the CheeseConnoisseur should be initialized with no cheese Execute trades until at least 3 Cheese objects are sentient. Create three classes to simulate cheese connoisseurs. One class representing the cheese (Cheese.java), one class representing the cheese connoisseurs (CheeseConnoisseur.java), and one class to run the simulation (Cheese Driver.java). Make sure to javadoc your code! There is no output for this program. Some restrictions - No imports are allowed. - Make sure to not use the following. var (the reserved keyword) System.exit Runtime.getRuntime.halt Runtime.getRuntime.exit Cheese.java File that represents some cheese from a grocery store. Once a cheese has been traded 3 times, it becomes sentient (becomes alive!). Instance Variables Pick appropriate variable types and names. All fields should follow the rules of encapsulation. - Holds the type of the cheese (such as Pepperjack, Cheddar) - Holds the price of the cheese - Holds whether or not this cheese is sentient - Holds a counter of how many times this specific Cheese object has been traded. - Holds how many cheese trades have happened across all cheeses * This variable should be the same across all instances of Cheese Constructors - A constructor that takes in the price, type, and number of trades for that specific Cheese instance. * A cheese should not be sentient at instantiation unless it has already been traded 3 times. - A constructor that takes in price, type. * A cheese should not be sentient at instantiation. * By default, a Cheese object has been traded 0 times. Methods - A toString method that converts a Cheese object to a String * If the cheese is not sentient, the String should be: "This is a slice of type) cheese that has been traded (number of trades) times. * If the cheese is sentient, the String should be: I am a slice of type) cheese that has been traded (number of trades] times. - An equals method (as learned in class) dependent on type, price, and sentience. * We're looking for an overloaded equals method here, not an overridden Object equals method. - A method for when a cheese is traded * Increment the appropriate variables * A cheese is sentient if it has been traded at least 3 times. When cheese becomes sentient, it doubles in price. . When cheese becomes sentient, it should print "I'm ALIIIIIVE! - getters/setters as needed CheeseConnoisseur.java File that represents a cheese connoisseur who owns a singular cheese. Instance Variables Pick appropriate variable types and names. All fields should follow the rules of encapsulation. - Holds the name of the connoisseur. - Holds one cheese owned by the connoisseur. - Holds how much money the connoisseur has. Constructors - One constructor that takes in name, money, and cheese - One constructor that takes in name, money * Should give the connoisseur a null Cheese that can be filled later. * This should use constructor chaining. - One constructor taking name. * The connoisseur should have no money. * The connoisseur should have no cheese at the moment. * This should use constructor chaining. - One constructor with no arguments. * The connoisseur's name should be "Louis Pasteur" * The connoisseur should own no cheese at the moment. * The connoisseur should have $20.00 Methods - One method that allows a CheeseConnoisseur to make a trade. It will take in a Cheese object. * The connoisseur should replace their current cheese with the cheese that is passed in to the method. * Both cheese trade variables should increase by 1 (instance and object) * If a cheese has been traded 3 times, it should become sentient. - Another method that allows a CheeseConnoisseur to make a trade. It will take in a CheeseConnoisseur. This method should overload the previous method. * If one of the cheese connoisseurs has a null cheese, the trade will not happen. * If the two cheeses are equal, the connoisseurs do not trade Cheese objects. * If they are not equal, the connoisseur who gives away the less expensive cheese should pay the difference, then they trade cheese. If they do not have enough money to pay the difference, the connoisseurs will not trade Cheese objects. Both cheese trade variables should increase by 1 (instance and object). If a cheese has been traded 3 times, it should become sentient. - Getters/setters as needed Cheese Driver.java A driver file that will run the simulation. Make sure to have the following in your Cheese Driver: Create at least 4 Cheese objects Create at least 2 CheeseConnoisseur objects. - One of the CheeseConnoisseur should be initialized with no cheese Execute trades until at least 3 Cheese objects are sentient

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

outline some of the current issues facing HR managers

Answered: 1 week ago