Question
Java Coding Question. Must be object oriented!!! No need to use encapsulation but can use it if helps No arraylists allowed I will make sure
Java Coding Question. Must be object oriented!!!
No need to use encapsulation but can use it if helps
No arraylists allowed
I will make sure to thumbs up. Please help me out.
You will build a university directory of student information and their penalties. At this university if students are caught plagiarising or cheating they are fined. For every student you will need to keep track of personal information as well as the backpack they have. At this university backpacks have special ID numbers.
Build a class named "Student" that has the following attributes
studentID: a string that represents the students id number for example "h6547-74848-jui5"
name: a string that represents the students name for example " Alex Jones"
address: a string that represents the address of the student for example "55 maple rd."
town: a string that represents the town the student lives in for example "London"
state: a string that represents the state the student lives in for example "Texas"
Add the following methods to the "Student" class
1) build a constructor method that has 5 parameters for the all the attributes. The parameters must be in same order as attributes. so it must be in order ( studentID, name, address, town, state)
2) build a constructor that has 0 parameters that calls the previous constructor with the appropriate values
3) build a toString() method that returns a string in the following way:
"#h6547-7gy48-jui5, Alex Jones resides at 55 Maple Rd. London, TX"
Build a class named "backpack"
brand: a string that represents the brand for example "jansport, nike, adidas"
type: a string that represents the type of backpack for example " big, small, one strap, rolling"
release: an int that represents the year the backpack was released for sale for example "2021, 2009, 1995"
colour : a string that represents colour of the backpack for example "yellow, pink, grey"
backpackID: a string that represents the custom ID of the backpack for example "7346yye7, dhf78, fhdeeys, 4663"
wearer: a Student object that represents the wearer of the backpak for example "Alex Jones" from the student class
was_stolen: a boolean representing if the backpack was reported for being stolen
Add the following methods to the "backpack" class
1) build a constructor method that has 5 parameters for the all the attributes. The parameters must be in same order as attributes. so it must be in order ( brand, type, release, colour, backpackID, wearer, was_stolen)
you must assume to start the backpacks are not stolen and there is no wearer yet.
2) build a constructor that has 0 parameters that calls the previous constructor with the appropriate values
3) build a toString() method that returns a string in the following way:
"yellow, 2021 nike one strap with ID: 7346yye7"
Build a class named "Penalty"
fine: a float that represents the monetary fine in $dollars of the penalty "5.5, 100, 33.33"
info: a string that represents the information of the penalty " cheating on exam, talking during class, skipping class"
date: a date that represents when the penalty happened import java.util.Date to do this.
paid: a boolean representing if the fine has been paid or is still pending
student: a Student object that represents the student who got the penalty for example "Alex Jones" from the student class
Add the following methods to the "Penalty" class
1) build a constructor method that has 3 parameters for the first 3 attributes. The parameters must be in same order as attributes. so it must be in order ( fine, info, date)
2) build a constructor that has 0 parameters that calls the previous constructor with the appropriate values
3) build a toString() method that returns a string in the following way:
"$5.5 penalty on Mon Jul 11 23:11:34 EDT 2020 [paid]"
Use String.format() so the fine shows 2 decimal places and to put the time. To format the string to display date use "%tc". If the penalty is paid it should display [paid] if it is not paid it should display [pending payment]
4) a method calling "paying_penalty" that pays the penalty. HINT: use outstanding attribute
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