Question

(10 marks) Question 1 Class Definitions la) (5 marks) Write information on Java class called IdentityCard to represent the th

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//1 a)
class IdentityCard
{
//instance variables
private String name;
private int idenityNumber;
private Image photo;
private boolean status;
//constructor
public IdentityCard(String name,int identityNumber,Image photo,boolean status)
{
this.name=name;
this.identityNumber=identityNumber;
this.photo=photo;
this.status=status;
}
//mutator for setting identity Number
public void setIdentityNumber(int identityNumber)
{
if(identityNumber>0)
this.identityNumber=identityNumber;
}
//accessor for getting identity number
public int getIdentityNumber()
{
return this.identityNumber;
}
}
// 1 b)
class DoorAccess
{
private ArrayList<IdentityCard> idCards;
//constructor
public DoorAccess(ArrayList<IdentityCard> idCards)
{
this.idCards=idCards;
}
//checkCardRemoval
boolean checkCardRemoval(IdentityCard idCard)
{
boolean found=false;
for(int i=0;i<idCards.size();++i)
{
if(idCards.get(i).getIdentityNumber()==idCard.getIdentityNumber())
{
found=true;
break;
}
}
if(found==true)
{
idCards.remove(i);
}
return found;
}
IdentityCard search(int identityNumber)
{
for(int i=0;i<idCards.size();++i)
{
if(idCards.get(i).getIdentityNumber()==identityNumber)
{
return idCards.get(i);
}
}   
return null;
}
}

Add a comment
Know the answer?
Add Answer to:
(10 marks) Question 1 Class Definitions la) (5 marks) Write information on Java class called IdentityCard...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design a class called Building. The class should keep the following information in the fields: String...

    Design a class called Building. The class should keep the following information in the fields: String address double property_value create several constructors including copy constructor , create accessor and mutator methods        Part 2 (50 points) Define interface Taxable which has one method getPropertyTax() Design a class called Private_Property that extends Building and implements Taxable It should have the following field : double value_of_improvements Create a constructor for this class to include newly added fields. The tax for the private property...

  • Question 1 (24 Marks] 1. (4 marks) Write an immutable Person class in Java which provides...

    Question 1 (24 Marks] 1. (4 marks) Write an immutable Person class in Java which provides the following. • Two attributes: lastName and first Name of type String. • Appropriate initialization, accessors/mutator methods. 2. (6 marks) Write a Student class that is a subclass of Person class (in the previous question) which provides the following. • Two attributes: A unique student ID of type String and GPA of type float; the student ID is initialized when a Student object gets...

  • java Write a class named Car that has the following fields: • yearModel: The yearModel field...

    java Write a class named Car that has the following fields: • yearModel: The yearModel field is an int that holds the car's year model. • make: The make field is a String object that holds the make of the car. • speed: The speed field is an int that holds the car's current speed. In addition, the class should have the following methods: • Constructor: The constructor should accept the car's year model and make as arguments. These values...

  • Using Java Write a class encapsulating the concept of student grades (50 elements) on a test,...

    Using Java Write a class encapsulating the concept of student grades (50 elements) on a test, assuming student grades are composed of a list of integers between 0 and 100. Write the following methods: A constructor with just one parameter, the number of students; all grades can be randomly generated Accessor, mutator, toString, and equals methods A method returning the highest grade A method returning the average grade A method returning the lowest grade Write a client class to test...

  • Write a Java object class Cat with the member variables (fields) color, breed, birthday, and weight....

    Write a Java object class Cat with the member variables (fields) color, breed, birthday, and weight. Create an empty constructor and overload that constructor and have it accept values for each member variable. There should be manipulator (setter) and accessor (getter) methods for each member variable. Ensure the Cat object has a toString() method. The accessor method for the birthday should return the date in the format MM/DD/YYYY. Add an accessor method getAgeInYears() that calculates how many years old the...

  • In C++, Step 1: Implement the Student Class and write a simple main() driver program to...

    In C++, Step 1: Implement the Student Class and write a simple main() driver program to instantiate several objects of this class, populate each object, and display the information for each object. The defintion of the student class should be written in an individual header (i.e. student.h) file and the implementation of the methods of the student class should be written in a corresponding source (i.e. student.cpp) file. Student class - The name of the class should be Student. -...

  • Suppose you were given the job to write a Java class to manage employee payroll information...

    Suppose you were given the job to write a Java class to manage employee payroll information in an HR management system. Each employee will be modeled as a single EmployeePayroll object (much like the Student objects discussed in class). The state of the EmployeePayroll object includes the first name and last name of the employee, a unique 15 digit employee number for each employee, a number of hours that they've worked this week (which could be a fraction of an...

  • java bluej Create a class called Vehicle, that contains five fields, current speed, power, accelerate, decelerate...

    java bluej Create a class called Vehicle, that contains five fields, current speed, power, accelerate, decelerate and top speed, all of which type is int.  Define a constructor that takes and sets the accelerate, decelerate; sets the power to 20, and top speed to 120. Leave the current speed as 0. Also define a constructor that takes no parameters. The power field should be set to the value of 30 in this constructor, top speed to 160, and accelerate and decelerate...

  • JAVA HELP Design a class named Employee. The class should keep the following information in fields:...

    JAVA HELP Design a class named Employee. The class should keep the following information in fields: Employee name Employee number in the format XXX–L, where each X is a digit within the range 0–9 and the L is a letter within the range A–M. Hire date then, Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to...

  • Java Program Write a class named Car that has the following fields: yearModel- The yearModel field...

    Java Program Write a class named Car that has the following fields: yearModel- The yearModel field is an int that holds the car’s year model. make- The make field is a String object that holds the make of the car, such as “Ford”, “Chevrolet”, etc. speed- This speed field is an int that holds the car’s current speed. In addition, the class should have the following methods: Constructor- The constructor should accept the car’s year model and make as arguments....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT