Lab3.docx - Object Oriented Programming[Lab 3 LAB 03 1...

This preview shows page 1 - 5 out of 17 pages.

29/03/21 Object Oriented Programming [Lab 3] LAB # 03 1. Task #1 : Consider a computer system whose name, type, processor specification, ram, hard disk drives, mother board, optical drive etc are its member variables and its desired values that cannot be accessed directly. They are entered by the user in a get method (that takes information from the user) and the displays the inputted information via display method. The user shall be asked to change any of the provided information if he/she agrees to change the information then new values shall be asked from the user.
29/03/21 Object Oriented Programming [Lab 3] switch(select) { case '1': System.out.print(" Enter Name: "); object.Getname(); break; case '2': System.out.print(" Enter Type: "); object.Gettype(); break; case '3': System.out.print(" Enter Processor: "); object.Getps(); break; case '4': System.out.print(" Enter RAM: "); object.Getram(); break; case '5': System.out.print(" HDD: "); object.Gethdd(); break; case '6': System.out.print(" MotherBoard: "); object.Getmb(); break; case '7': System.out.print(" Optical Drive : "); DUA E SAMEEN (02-131202-060) 2
29/03/21 Object Oriented Programming [Lab 3] object.Getodrive(); break; } System.out.println("UpdatedInformation is: "); object.Display(); } else { System.out.println("The end!"); } } while(c=='y'); } } package lab31; import java.util.*; public class comp { private String ps; private String name; private String ram; private String type; private String hdd; private String mb; private String odrive; Scanner input=new Scanner(System.in); public String Getps() { DUA E SAMEEN (02-131202-060) 3
29/03/21 Object Oriented Programming [Lab 3] ps = input.next(); return ps; } public String Gettype() { type = input.next(); return type; } public String Gethdd() { hdd= input.next(); return hdd; } public String Getram() {

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture