Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

May I please have a UML Diagram created for this Computer Science project? I have completed the program and only require a UML Diagram for

May I please have a UML Diagram created for this Computer Science project? I have completed the program and only require a UML Diagram for it. I will give the code for my program in here as well.

public class Car { private String vin; private String make; private String model; private double cost; int year;

public Car(String vin, String make, String model, double cost, int year) { this.vin = vin; this.make = make; this.model = model; this.cost = cost; this.year = year; } public double getCost() { return cost; }

public String getMake() { return make; }

public boolean isExpensive() { if(this.cost>30000) return true; else return false; }

public boolean isAntique() { if(this.year<1968) return true; else return false; }

public String toString() { return "" + vin + "\t" + make + "\t" + model + "\t" + cost + "\t" + year + ""; } }

import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Scanner; public class CarList { ArrayList carsList = new ArrayList(); public CarList() throws IOException { Scanner br2 = new Scanner(new File("InData.txt")); String str=""; while(br2.hasNext()) { String vin = br2.next(); String make = br2.next(); String model = br2.next(); double cost = br2.nextDouble(); int year = br2.nextInt();

Car c = new Car(vin, make, model, cost, year); carsList.add(c); } }

public void printList() { for(Car c:carsList) { System.out.println(c.toString());

} }

public void printExpensiveCars() { for(Car c:carsList) { if(c.isExpensive()) System.out.println(c.toString()); } } public Car oldestCar(){ Car oldestCar = carsList.get(0); for(Car c:carsList) { if(c.year < oldestCar.year){ oldestCar = c; } } return oldestCar; } public int countCarsWithMake(String make) { int count=0; for(Car c:carsList) { if(c.getMake().equals(make)) count++; } if (count==0){ System.out.println("there are no cars with specified make"); } if (count>0){ System.out.println("Amount of Cars with the make is: "+ count); } return count; }

public ArrayList antiqueExpensiveCarList() { ArrayList antique = new ArrayList(); for(Car c:carsList) { if(c.isAntique() && c.isExpensive()) antique.add(c) ; } return antique; } }

import java.io.IOException; public class TestCarList { public static void main(String[] args) throws IOException { CarList cl = new CarList(); System.out.println("List of Cars are:"); cl.printList(); System.out.println(); System.out.println("Cars That Are Expensive (over $30,000):"); cl.printExpensiveCars(); System.out.println(); System.out.println("The oldest Car is :"); System.out.println(cl.oldestCar()); System.out.println(); cl.countCarsWithMake("Honda"); System.out.println(); System.out.println("List of Cars that are both Antique & Expensive:"); System.out.println(cl.antiqueExpensiveCarList()); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

Will you actually use Model 7.3 to motivate yourself?

Answered: 1 week ago

Question

Bring out the limitations of planning.

Answered: 1 week ago

Question

Why should a business be socially responsible?

Answered: 1 week ago

Question

Discuss the general principles of management given by Henri Fayol

Answered: 1 week ago

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago