Showing posts from February, 2017

Task 4 - The Lucky Racer Game

Last Updated: Oct. 10, 2020 Please note that, focus of this task is not on single topic. It covers most of concepts you have learned so far. The most important point where I need you attention is, do not focus on meeting the functional requirements only, but also on where a specific code should be written, what fields should be allowed to be read by other objects and which ones should be kept private. So, take the object oriented design into account and develop using best approach as per best of your OOP understooding. Create AutomaticCar class that shall have private model, year, speed and gear attributes. Encapsulate complete state and expose the state for read/write (where it makes sense and needed). As its automatic car, so other shall not be able to update the gear attribute directly. The gear would auto change based on speed and other parameters (defined below). The speed range for different gears is (gear : speed-range) 0:0 1:1-100 2:101-200 3:201-300 4:301-400 5:401-5

Task 3 - Constructors and Constructor Overloading

Updated On: Oct. 5, 2020 Task 3.1   Create a Circle class such that it shall be mandatory for the user to pass the radius when a new object of  type Circle is instantiated. Otherwise, the object shall not be instantiated. Fully encapulsulate the radius field and expose its via getter and setter methods for public access to read and update the attribute. Make sure, its value must be greater than 0. Define calculateArea and calculatePerimeter methods with public access modifiers. Task 3.2 Junaid has decided to open new bank that would encourage savings and discourage expenses or spending; his target is to attract younger people. He has seed/surplus money to spend to gain customers. He has made following initial policies about the bank account: Create constructors for Account class in such a way that, the object of account shall be created by passing accountId(for existing accounts) or CNIC, name and age (for new account). Otherwise the Account object shall not be created. Define the co

Task 2 : Classes, Instance Attributes and Methods

Post Updated on: Sep. 26, 2020 Task Objectives Defining a class with instance attributes and methods Accessing instance attributes from methods How to call methods from out side the object How to decided what additional attributes we may need to fullfil some some requirement How object oriented design help us to write code that is better maintainable. Part 1 Make BankAccount class that shall have  balance and name attributes of type double and String . Implement  void deposit(double amount) and void withdraw(double amount) methods inside the BankAccount class. The deposit  method shall increase the balance by passed value and withdraw  method should decrease the balance with passed amount. Make BankAccountTest class. Inside its main(String args[]) method, create a new object of BankAccount class. Get balance and name of account holder from user input and use user entered data to initilize object instance attributes.  After the object is created and initialized, show this menu to user

Task 01 - Java Basics

Post Updated on: Sep. 18. 2021 Task 01 Objects: Writing, compiling and running basic program in Java Using primitive data types and their literals Getting input from user of different primitive types Using if/else, loops and defining methods in Java Below given tasks are very basic in nature. They are to make you comfortable with how to write code in Java using variables, if/else and loops, printing output at console using different methods. 1.1  Initialize a variable n with some +ve integer value. Then create implement logic to print first n prime numbers on console.  1.2 Declare and initialize byte, short, int, float, long, double, boolean type variables using literals, change those values by user input and then print all of 7 variables on console. (in lab video, you have already seen, how to get input from user using Scanner class) 1.3  Get a 4 digit integer number from user input and print each digits on a separate line. 1.4  Get an integer from user that represent a year, it must