Question
You have to create a design document for each problem and follow steps 1-6 in HowTo 3.1 Programming Projects P3.9 P3.12 and P3.14 (10 points
- You have to create a design document for each problem and follow steps 1-6 in HowTo 3.1
- Programming Projects P3.9 P3.12 and P3.14 (10 points each)
- Modify three classes for drawing cars ( Car.java, CarComponet.java, CarViewer.java). create the third car - Put all of them next to each other - paint all tires black - paint first car yellow, second car red, third car white - Create the fourth car below the other three and centered with double all measurements - The fourth car is twice bigger than the other three.
- p3.9:
Write a class Battery that models a rechargeable battery. A battery has a constructor public Battery(double capacity)
where capacity is a value measured in milliampere hours. A typical AA battery has a
capacity of 2000 to 3000 mAh. The method
public void drain(double amount)
drains the capacity of the battery by the given amount. The method
public void charge()
charges the battery to its original capacity. The method
public double getRemainingCapacity()
gets the remaining capacity of the battery.
-
P3.12: Implement a VotingMachine class that can be used for a simple election. Have methods to clear the machine state, to vote for a Democrat, to vote for a Republican, and to get the tallies for both parties.
-
In this project, you will explore an object-oriented alternative to the Hello, World program in Chapter 1.
Begin with a simple Greeter class that has a single method, sayHello. That method should return a string, not print it. Create two objects of this class and invoke their sayHello methods. Of course, both objects return the same answer.
Enhance the Greeter class so that each object produces a customized greeting. For example, the object constructed as new Greeter("Dave") should say "Hello, Dave". (Use
the concat method to combine strings to form a longer string, or peek ahead at Section 4.5 to see how you can use the + operator for the same purpose.)
Add a method sayGoodbye to the Greeter class. Finally, add a method refuseHelp to the Greeter class. It should return a string such as
"I am sorry, Dave. I am afraid I cant do that."
If you use BlueJ, place two Greeter objects on the workbench (one that greets the world and one that greets Dave) and invoke methods on them. Otherwise, write a tester program that constructs these objects, invokes methods, and prints the results.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started