Question

JAVA A. Create a class to hold information about subcontractors and allow that information to be...

JAVA

A. Create a class to hold information about subcontractors and allow that information to be read and changed.

B. Create a class to hold information about contracts and allow that information to be read and changed. Everything except the list of subcontractors should be included at this item.

C. Create a class to hold information about contracts and allow that information to be read and changed. Only the list of subcontractors should be included at this item.

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

implemented following classes:

Subcontractor: to store individual Subcontractor details.

Subcontractors: to store list of Subcontractor

Contract: to store individual Contract

Contracts: to store list of Contracts.

SubContractor.java

package Examples;

public class SubContractor {

String name;

String id;

SubContractor(String name,String id){

this.name= name;

this.id = id;

}

public void setName(String name) {

this.name = name;

}

public void setId(String id ) {

this.id = id;

}

public String getName() {

return this.name;

}

public String getId() {

return this.id;

}

}

Subcontractors.java

package Examples;

import java.util.*;

public class SubContractors {

public static void main(String[] args) {

// TODO Auto-generated method stub

List<SubContractor> sublist = new ArrayList<SubContractor>();

SubContractor sc1 =new SubContractor("john","a121");

SubContractor sc2 =new SubContractor("chris","a122");

SubContractor sc3 =new SubContractor("rosey","a123");

sublist.add(sc1);

sublist.add(sc2);

sublist.add(sc3);

for(SubContractor scs:sublist) {

System.out.println(scs.getName()+" "+scs.getId()+" ");

}

}

}

Contract.java

package Examples;

public class Contract {

String id,description,name;

Contract(String id,String description,String name){

this.id = id;

this.description = description;

this.name = name;

}

public void setId(String id) {

this.id = id;

}

public void setDescription(String description) {

this.description = description;

}

public void setName(String name)

{

this.name = name;

}

public String getName() {

return this.name;

}

public String getId() {

return this.id;

}

public String getDescription() {

return this.description;

}

}

Contracts.java

package Examples;

import java.util.ArrayList;

import java.util.List;

public class Contracts {

public static void main(String[] args) {

// TODO Auto-generated method stub

List<Contract> clist = new ArrayList<Contract>();

Contract cs1 = new Contract("c111","emai service for plug in ","email service");

Contract cs2 = new Contract("c112","tel service for plug in ","tele service");

clist.add(cs1);

clist.add(cs2);

for(Contract css: clist) {

System.out.println(css.id+" "+css.description+" "+css.name);

}

List<SubContractor> sublist = new ArrayList<SubContractor>();

SubContractor sc1 =new SubContractor("john","a121");

SubContractor sc2 =new SubContractor("chris","a122");

SubContractor sc3 =new SubContractor("rosey","a123");

sublist.add(sc1);

sublist.add(sc2);

sublist.add(sc3);

for(SubContractor scs:sublist) {

System.out.println(scs.getName()+" "+scs.getId()+" ");

}

}

}

output for Subcontractors.java execution:

john a121

chris a122

rosey a123

output for Contracts.java

c111 emai service for plug in email service

c112 tel service for plug in tele service

john a121

chris a122

rosey a123

comments:

the above code is executable one with output screenshots.

please comment me if any queries...thanks

Add a comment
Know the answer?
Add Answer to:
JAVA A. Create a class to hold information about subcontractors and allow that information to be...
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
  • Write code to create a Java class called "Student". The class should hold information about a...

    Write code to create a Java class called "Student". The class should hold information about a student: name, id and whether or not the student is currently registered. There should be a constructor that takes name, id and registration status. Add getters and setters for the three properties. Make sure that you use appropriate visibility modifiers (public vs. private).

  • in Java, Declare a partial array to hold String values. Allow the user to determine the...

    in Java, Declare a partial array to hold String values. Allow the user to determine the size of the array and to enter a number of tasks into the array. Print a numbered list of the tasks (numbering must start at 1). The list should display only those array elements that contain tasks – empty elements should be ignored.

  • Java using data structures The objective is to create your own Hash Table class to hold...

    Java using data structures The objective is to create your own Hash Table class to hold a list of employees and their ID numbers. I've provided the TableEntry class which will be each data object in the hash table. The list of employees will be provided as a .txt file and must be read with the code. please create a .txt file called Employees.txt with the info provided so that the java code can read it in. Employees.txt: (No WhiteSpace...

  • Create a class in Java with instance variables to hold the name, street address, city, and...

    Create a class in Java with instance variables to hold the name, street address, city, and state for a user. These instance variables should be private. You should enter the name and address in the nameAddress method. You should enter the city and state in the cityState method. In the main method, print the complete address using the method printAddress. You should not use the static keyword except for the main method. Your output should be similar to the output...

  • JAVA PROGRAMME A class called “Gallery” to hold information in an auto gallery catalog It will...

    JAVA PROGRAMME A class called “Gallery” to hold information in an auto gallery catalog It will be described. “Gallery” class, brand (String) belonging to cars, model (int), price (double), color (String) will hold the fuel type (String) and body type (String) attributes. Also a class named “Mother” It will be. Values will be assigned to the properties of the “Gallery” class, and objects will be produced through this class. a. Write the specified classes in Java programming language. b. By...

  • JAVA PROGRAMMING PLEASE This lab has three parts: Create an ArrayList class. Create a LinkedList class....

    JAVA PROGRAMMING PLEASE This lab has three parts: Create an ArrayList class. Create a LinkedList class. Print out the results after testing each of the methods in both of the classes and solving a simple problem with them. Task 1 – ArrayList Class Create an ArrayList class. This is a class that uses an internal array, but manipulates the array so that the array can be dynamically changed. This class should contain a default and overloaded constructor, where the default...

  • Complex number class:: Question Changed to just the Java portion Design a class in and Java...

    Complex number class:: Question Changed to just the Java portion Design a class in and Java that represents complex numbers and supports important operations such as addition, subtraction, multiplication and division. (the following is for the c++ and python version, not sure if its needed for this) op: Complex × Complex → Complex op: Complex × double → Complex op: double × Complex → Complex Where op is one of +, -, *, or /. In addition, you will need...

  • Create a Java application, that support the following: Create an Employee class, which holds following information:...

    Create a Java application, that support the following: Create an Employee class, which holds following information: Employee First Name Employee Last Name Employee Phone Number Employee Address Employee id Employee Title Employee salary Create an application that uses the Employee class Constructors –Getters and setters A minimum of 3 constructors including default constructor equals() method Helper methods toString() method Create an array of 5 Employee objects Use a Scanner to read in 5 employee information Change 2 employees information (3-items...

  • Help with Java Program Please Create a simple graph class. The graph class should have the...

    Help with Java Program Please Create a simple graph class. The graph class should have the following items: an adjacency list or matrix to hold the graph data variables to hold the current size and max size of the graph default constructor create empty adjacency list/matrix max size = 10 overloaded constructor create empty adjacency list/matrix max size = int parameter isEmpty check if current size is zero createGraph read a formatted file and fill adjacency list/matrix The first line...

  • In Java: DATA TYPE CLASS Create one data type class Account_yourLastName that hold the information of...

    In Java: DATA TYPE CLASS Create one data type class Account_yourLastName that hold the information of an account such as accountNumber (String), name (String), address (String), balance (float), interestRate(float) and beside the no-argument constructor, parameterized constructor, the class has method openNewAccount, method checkCurrentBalance, method deposit, method withdrawal, method changeInterestRate REQUIREMENT - DRIVER CLASS Provide the application for the Bank Service that first displays the following menu to allow users to select one task to work on. After finishing one task,...

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