Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mariusherlea homework4 #125

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
393f6c2
Merge remote-tracking branch 'origin/master'
mariusherlea Dec 20, 2019
7443d8d
Merge remote-tracking branch 'origin/master'
mariusherlea Dec 20, 2019
dc81faf
Merge remote-tracking branch 'origin/master'
mariusherlea Dec 20, 2019
a5a68ad
Merge remote-tracking branch 'origin/master'
mariusherlea Dec 22, 2019
5c4fec3
Merge remote-tracking branch 'origin/master'
mariusherlea Dec 28, 2019
9d19733
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 1, 2020
318eb29
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 3, 2020
1075ef6
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 4, 2020
d3fd856
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 6, 2020
ddb7557
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 6, 2020
d9bf9f8
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 6, 2020
0005015
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 8, 2020
13a1dc4
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 8, 2020
80046dc
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 8, 2020
66ac83f
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 8, 2020
5c3b19c
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 13, 2020
0d697a0
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 13, 2020
7b3d5fe
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 18, 2020
872bfba
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 19, 2020
340db70
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 20, 2020
2ebd667
Merge remote-tracking branch 'origin/master'
mariusherlea Jan 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/com/pentalog/pentastagiu/homework3/bluetooth/BluetoothAp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

//Create a console application from the following requirements:
//In the application we will work with few things: cars, phones, smart refrigerators. Add some specific details for each one
//We want each of these things to be able to connect with bluetooth → write a Connectable interface in which you specify this contract: a method called connectToBluetooth
//Add another simple class, Student for example, which doesn’t have to implement the Connectable interface
//Implement this contract in each class that you have and add a specific implementation
// (in which you just print to console a message in which you specify: “Connect to bluetooth in progress...” and the name of
// the device)


package com.pentalog.pentastagiu.homework3.bluetooth;

import java.util.ArrayList;
import java.util.List;

import static javafx.scene.input.KeyCode.T;


public class BluetoothAp {




public static void main(String[] args) {
Cars car1 = new Cars();
Phones phone1 = new Phones();
SmartRefigerators ref1 = new SmartRefigerators();
Students stud1 = new Students();

List<Object> objects = new ArrayList<>();
objects.add(car1);
objects.add(phone1);
objects.add(ref1);
objects.add(stud1);

for(Object x : objects) {
if (x instanceof Items){
System.out.println(x.getClass()+ " "+((Items) x).connectToBluetooth());
} else
{

System.out.println(x.getClass()+" Unable to connect to bluetooth");
}
}

}
}
9 changes: 9 additions & 0 deletions src/com/pentalog/pentastagiu/homework3/bluetooth/Cars.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.pentalog.pentastagiu.homework3.bluetooth;

public class Cars extends Items{
private int EnginePistons;
private int GearsNumbers;



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.pentalog.pentastagiu.homework3.bluetooth;

public interface Connectable {
public String connectToBluetooth();
}
8 changes: 8 additions & 0 deletions src/com/pentalog/pentastagiu/homework3/bluetooth/Items.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.pentalog.pentastagiu.homework3.bluetooth;

public class Items implements Connectable {
@Override
public String connectToBluetooth() {
return ("Connect to bluetooth in progress...");
}
}
7 changes: 7 additions & 0 deletions src/com/pentalog/pentastagiu/homework3/bluetooth/Phones.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.pentalog.pentastagiu.homework3.bluetooth;

public class Phones extends Items{
private String Os;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.pentalog.pentastagiu.homework3.bluetooth;

public class SmartRefigerators extends Items{
private int Capacity;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.pentalog.pentastagiu.homework3.bluetooth;

public class Students {
private String name;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

//Create an application that knows how to calculate the perimeter and area for common shapes(circle, square, rectangle, triangle)
//To test it: create few objects of each type and print to the console information about the object that has the biggest area

package com.pentalog.pentastagiu.homework3.perimeterAndArea;

import com.sun.deploy.security.WinDeployNTLMAuthCallback;

import java.util.ArrayList;
import java.util.List;

public class MainApp {




public static void main(String[] args) {
List<Shape> shapes = new ArrayList<>();
Rectangle drept=new Rectangle(19,12);
System.out.println(drept.area());
System.out.println(drept.perimeter());
Square patra=new Square(11);
System.out.println(patra.area());
System.out.println(patra.perimeter());
shapes.add(drept);

shapes.add(patra);
int ariaCeaMaiMare = 0;

int index = 0;
int i = 0;
for (Shape shape : shapes) {
// System.out.println("shape = " + shape + " i" + i);
//adunare arie cea mai mare
if (ariaCeaMaiMare < shape.area()) {

ariaCeaMaiMare = shape.area();
index=shapes.indexOf(shape);

}
i++;
}
System.out.println("Aria cea mai mare o are = " + shapes.get(index));

}




}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.pentalog.pentastagiu.homework3.perimeterAndArea;

public class Rectangle extends Shape {

private static int width;
private static int length;

public Rectangle(int width, int length) {
this.width = width;
this.length = length;
}

public int getWidth() {
return width;
}

public void setWidth(int width) {
this.width = width;
}

public int getLength() {
return length;
}

public void setLength(int length) {
this.length = length;
}

@Override
public int perimeter() {
return 2*(width+length);
}


public int area() {
return width*length;
}



@Override
public String toString() {
return "Square{" +
"length" +length+
"width= " + width + "area "+area()+"peimetru "+perimeter();
}
}
10 changes: 10 additions & 0 deletions src/com/pentalog/pentastagiu/homework3/perimeterAndArea/Shape.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.pentalog.pentastagiu.homework3.perimeterAndArea;

public abstract class Shape {

public abstract int perimeter();

public abstract int area();


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.pentalog.pentastagiu.homework3.perimeterAndArea;

public class Square extends Shape {

private static int a;


public Square(int a) {
this.a = a;
}

public int getA() {
return a;
}

public void setA(int a) {
this.a = a;
}


public int perimeter() {
return 4*a;
}


public int area() {
return a*a;
}



@Override
public String toString() {
return "Square{" +
"a='" + a + "area "+area()+"perimetru "+perimeter();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.pentalog.pentastagiu.homework3.restaurant;

public class FastFoodRestaurant extends Restaurant {


public FastFoodRestaurant(int priceForFixedMenu) {
super(priceForFixedMenu);
}

@Override
public void calculateIncomeAndTaxes() {
System.out.println("Income are " + (getIncome()*0.8));
System.out.println("Taxes are " +(getIncome()*0.2));
}
}
28 changes: 28 additions & 0 deletions src/com/pentalog/pentastagiu/homework3/restaurant/MainApp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

//Create a console application that works with restaurants
//Each restaurant will have info about the current number of guests, the income, the price for a fixed menu
//Each restaurant will have a method that accommodates new guest in which the number of current guests has to increase with the number of new guests and the income also will increase accordingly(each new guest will consume a fixed price menu).
//We will also have the option of calculating the taxes that each restaurant has to pay to the local authorities, but each restaurant will have a different way of calculating this
//Let's consider that we will have 2 types of restaurants: vegetarian restaurant and fast food restaurant.
// Each restaurant will have to pay taxes to the local authorities, which represent 20% of their income. Also the local authorities from the town where we have restaurants,
// that want to encourage a healthy life, decided that the vegetarian restaurant will receive a discount of 30% for the taxation.
//Implement for each restaurant a method that calculates the tax that it has to pay.

package com.pentalog.pentastagiu.homework3.restaurant;

public class MainApp {
public static void main(String[] args) {
FastFoodRestaurant fast1=new FastFoodRestaurant(10);
fast1.accommodateGuest(5);
System.out.println("FastFood Restaurant");
System.out.println(fast1.getTotalNumberOfGuest());
fast1.calculateIncomeAndTaxes();

VegetarianRestaurant veg1=new VegetarianRestaurant(10);
veg1.accommodateGuest(5);
System.out.println("Vegetarian Restaurant");
System.out.println(veg1.getTotalNumberOfGuest());
veg1.calculateIncomeAndTaxes();

}
}
44 changes: 44 additions & 0 deletions src/com/pentalog/pentastagiu/homework3/restaurant/Restaurant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.pentalog.pentastagiu.homework3.restaurant;

public abstract class Restaurant {
private int numberOfGuest = 0;
private int income = 0;
private int priceForFixedMenu;
private int totalNumberOfGuest;

public int getNumberOfGuest() {
return numberOfGuest;
}

public void setNumberOfGuest(int numberOfGuest) {
this.numberOfGuest = numberOfGuest;
}

public int getTotalNumberOfGuest() {
return totalNumberOfGuest;
}

public int getPriceForFixedMenu() {
return priceForFixedMenu;
}

public void setPriceForFixedMenu(int priceForFixedMenu) {
this.priceForFixedMenu = priceForFixedMenu;
}

public int getIncome() {
return income;
}

public Restaurant(int priceForFixedMenu) {
this.priceForFixedMenu = priceForFixedMenu;
}

public void accommodateGuest(int numberOfGuest) {
totalNumberOfGuest = totalNumberOfGuest + numberOfGuest;
income=priceForFixedMenu*totalNumberOfGuest;
}

public abstract void calculateIncomeAndTaxes();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.pentalog.pentastagiu.homework3.restaurant;

public class VegetarianRestaurant extends Restaurant {


public VegetarianRestaurant(int priceForFixedMenu) {
super(priceForFixedMenu);
}

@Override
public void calculateIncomeAndTaxes() {
double interIncome=getIncome()*0.8;
double interTaxes=getIncome()*0.2;
double refund =interTaxes*0.3;
double finalIncome=interIncome+refund;
double finalTaxes=interTaxes-refund;
System.out.println("Income are " + finalIncome);
System.out.println("Taxes are " +finalTaxes);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.pentalog.pentastagiu.homework3.strategyGame;

public class Animal extends Character {
public Animal(int x, int y, String name, int energyPoints, int healthPoints) {
super(x, y, 0, name, energyPoints, healthPoints);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.pentalog.pentastagiu.homework3.strategyGame;

public class Artifact extends Items {

public Artifact(int x, int y) {
super(x, y);

}
}
Loading