Starting from:

$30

Lab 3 Solution

For today’s lab you will be doing three exercises pertaining to basic object orientation. Incorporate all the concepts we covered in class.




Office Hours Reminder




TAs:




Dustin Riley, rileydm3@miamioh.edu , Tuesday 730-830pm Benton 002




Emily Pantuso, pantusen@miamioh.edu , Monday 700-800pm Benton 002




Gage Laufenberg, laufengd@miamioh.edu , Tuesday 830-930pm Benton 002 Michael Gentile, gentilm5@miamioh.edu , Friday 6-7pm Benton 006




Professor Dr. Matthew Stephan, Office Hours Tuesday & Thursday 2:30pm-4:00pm, and by appointment




Part 1 (13 points)




Implement a class Address. (1 points)




An address has




A house number, 2. A street, 3. an optional (positive 0) apartment number, 4. City 5. a state 6. and an (positive 0, 5 digit) integer zip code. Implement these in your class, along with getters and smart setters as shown in class. (6 points)



Supply two constructors: one that configures everything, and one for all but an apartment number. (2 points)




Supply a print method that prints the address with the street on one line, and the city; state; and zip code on the next line. (2 points)




Supply a method public boolean comesBefore(Address other) that tests whether this address comes before another when the addresses are compared by postal code. (2 points)




Part 2 (5 points)




Implement a VotingMachine class that can be used for a simple election. (1 point) Have methods to




Clear the machine state (1 point)



To vote for a Democrat (1 point)
CSE 271 – Due 11:59pm @ Feb 14 (Thursday Labs); @ Feb 15 (Friday Labs) Lab 3













To vote for a Republican (1 point)



To get the tallies for both parties. (1 points)












Part 3 (9 points)







Implement a class Student. (1 point)




For the purpose of this exercise, a student has a name and a total quiz score. Include getters and smart setters, like we did in class. (2 points)




Supply an appropriate (all variables) constructor (1 point)




Implement methods (4 points)




getName()



addQuiz(int score) . Score must be a positive integer from 0 to 100.



getTotalScore()



getAverageScore(). To compute the latter, you also need to store the number of quizzes that the student took. (1 point)



Submission




Turn in a .zip of your three .java files to Canvas by your appropriate due date. Ensure you have actually submitted (received confirmation and checked online), since no late labs will be accepted.




Additional Rubric Details




3 points – Comments, Efficiency, File Naming Additional points can be deducted, however.




Grading will be based on conforming to the standards we reviewed in class as well as following the requirements of this lab.

More products